diff --git a/.idea/altmedia.iml b/.idea/altmedia.iml index 3aac297c..e99c7d52 100644 --- a/.idea/altmedia.iml +++ b/.idea/altmedia.iml @@ -198,7 +198,7 @@ - + diff --git a/app/models/bibliographic/host_bib_task.rb b/app/models/bibliographic/host_bib_task.rb index c03591e1..6fc65512 100644 --- a/app/models/bibliographic/host_bib_task.rb +++ b/app/models/bibliographic/host_bib_task.rb @@ -6,6 +6,7 @@ class HostBibTask < ActiveRecord::Base succeeded: 6, failed: 9 }, default: :starting + validates :email, presence: true class << self def create_from!(file, email) @@ -38,7 +39,7 @@ def upload_errors(file, mms_ids) def create_bib_task!(host_bib_task, mms_ids) ActiveRecord::Base.transaction do - host_bib_task.save + host_bib_task.save! attributes = mms_ids.map do |mms_id| # The default value 'pending' won't be included in bulk inserts. { mms_id:, host_bib_task_id: host_bib_task.id, marc_status: 'pending' } diff --git a/spec/data/calnet/013191303.yml b/spec/data/calnet/013191303.yml index 3740611c..c3884f0d 100644 --- a/spec/data/calnet/013191303.yml +++ b/spec/data/calnet/013191303.yml @@ -11,3 +11,4 @@ extra: uid: "013191303" berkeleyEduIsMemberOf: - cn=edu:berkeley:org:libr:framework:alma-admins,ou=campus groups,dc=berkeley,dc=edu + berkeleyEduAlternateID: ethomas@berkeley.edu diff --git a/spec/data/calnet/013191305.yml b/spec/data/calnet/013191305.yml index 8e696fcd..662ead82 100644 --- a/spec/data/calnet/013191305.yml +++ b/spec/data/calnet/013191305.yml @@ -11,3 +11,4 @@ extra: uid: "013191305" berkeleyEduIsMemberOf: - cn=edu:berkeley:org:libr:framework:LIBR-framework-admins,ou=campus groups,dc=berkeley,dc=edu + berkeleyEduAlternateID: ethomas@berkeley.edu diff --git a/spec/lib/bibliographic/report_spec.rb b/spec/lib/bibliographic/report_spec.rb index e196989f..a273cd76 100644 --- a/spec/lib/bibliographic/report_spec.rb +++ b/spec/lib/bibliographic/report_spec.rb @@ -2,7 +2,7 @@ module Bibliographic RSpec.describe Report do - let(:host_bib_task) { Bibliographic::HostBibTask.create(filename: 'fake.txt') } + let(:host_bib_task) { Bibliographic::HostBibTask.create(filename: 'fake.txt', email: 'test@test.example') } let(:report) { described_class.new(host_bib_task, 6) } # succeed mmsids for csv content diff --git a/spec/models/host_bib_spec.rb b/spec/models/host_bib_spec.rb index 390ce60c..a334e95d 100644 --- a/spec/models/host_bib_spec.rb +++ b/spec/models/host_bib_spec.rb @@ -4,7 +4,7 @@ RSpec.describe Bibliographic::HostBib, type: :model do let(:record_id) { double('record_id') } let(:mms_id) { '991083840969706532' } - let(:host_bib_task) { Bibliographic::HostBibTask.create(filename: 'fake.txt') } + let(:host_bib_task) { Bibliographic::HostBibTask.create(filename: 'fake.txt', email: 'test@test.example') } let(:marc_stub) { instance_double(MARC::Record) } let(:expected_subfields) { { 'w' => '991083840969706532', 't' => 'Seconde partie du discours aux Welches ' } } @@ -42,6 +42,22 @@ def marc_stub end end + describe 'task creation' do + context 'without an email address' do + it 'is invalid' do + task = Bibliographic::HostBibTask.new(filename: 'fake.txt', email: nil) + expect(task).not_to be_valid + end + end + + context 'with an email address' do + it 'is valid' do + task = Bibliographic::HostBibTask.new(filename: 'fake.txt', email: 'test@test.example') + expect(task).to be_valid + end + end + end + context 'host_bib not nil' do it_behaves_like 'host_bib has alma marc', 'pending' it_behaves_like 'host_bib has alma marc', 'retrieving' diff --git a/spec/models/linked_bib_spec.rb b/spec/models/linked_bib_spec.rb index f260b813..3f481bc2 100644 --- a/spec/models/linked_bib_spec.rb +++ b/spec/models/linked_bib_spec.rb @@ -3,7 +3,7 @@ RSpec.describe Bibliographic::LinkedBib, type: :model do let(:mms_id) { '991083840969706532' } - let(:host_bib_task) { Bibliographic::HostBibTask.create(filename: 'fake.txt') } + let(:host_bib_task) { Bibliographic::HostBibTask.create(filename: 'fake.txt', email: 'test@test.example') } let(:host_bib) { host_bib_task.host_bibs.create(mms_id:) } let(:subfields_from_774) { { 'w' => '991083840969706532', 't' => 'Seconde partie du discours aux Welches ' } }