Skip to content

Commit 8d7527e

Browse files
committed
models: Validate Bibliographic::HostBibTask.email
This ensures we do not create jobs without email addresses. Closes: AP-577
1 parent b6594c0 commit 8d7527e

File tree

5 files changed

+21
-4
lines changed

5 files changed

+21
-4
lines changed

.idea/altmedia.iml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/models/bibliographic/host_bib_task.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class HostBibTask < ActiveRecord::Base
66
succeeded: 6,
77
failed: 9
88
}, default: :starting
9+
validates :email, presence: true
910

1011
class << self
1112
def create_from!(file, email)

spec/lib/bibliographic/report_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module Bibliographic
44
RSpec.describe Report do
5-
let(:host_bib_task) { Bibliographic::HostBibTask.create(filename: 'fake.txt') }
5+
let(:host_bib_task) { Bibliographic::HostBibTask.create(filename: 'fake.txt', email: '[email protected]') }
66
let(:report) { described_class.new(host_bib_task, 6) }
77

88
# succeed mmsids for csv content

spec/models/host_bib_spec.rb

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
RSpec.describe Bibliographic::HostBib, type: :model do
55
let(:record_id) { double('record_id') }
66
let(:mms_id) { '991083840969706532' }
7-
let(:host_bib_task) { Bibliographic::HostBibTask.create(filename: 'fake.txt') }
7+
let(:host_bib_task) { Bibliographic::HostBibTask.create(filename: 'fake.txt', email: '[email protected]') }
88
let(:marc_stub) { instance_double(MARC::Record) }
99
let(:expected_subfields) { { 'w' => '991083840969706532', 't' => 'Seconde partie du discours aux Welches ' } }
1010

@@ -42,6 +42,22 @@ def marc_stub
4242
end
4343
end
4444

45+
describe 'task creation' do
46+
context 'without an email address' do
47+
it 'is invalid' do
48+
task = Bibliographic::HostBibTask.new(filename: 'fake.txt', email: nil)
49+
expect(task).to be_invalid
50+
end
51+
end
52+
53+
context 'with an email address' do
54+
it 'is valid' do
55+
task = Bibliographic::HostBibTask.new(filename: 'fake.txt', email: '[email protected]')
56+
expect(task).to be_valid
57+
end
58+
end
59+
end
60+
4561
context 'host_bib not nil' do
4662
it_behaves_like 'host_bib has alma marc', 'pending'
4763
it_behaves_like 'host_bib has alma marc', 'retrieving'

spec/models/linked_bib_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
RSpec.describe Bibliographic::LinkedBib, type: :model do
55
let(:mms_id) { '991083840969706532' }
6-
let(:host_bib_task) { Bibliographic::HostBibTask.create(filename: 'fake.txt') }
6+
let(:host_bib_task) { Bibliographic::HostBibTask.create(filename: 'fake.txt', email: '[email protected]') }
77
let(:host_bib) { host_bib_task.host_bibs.create(mms_id:) }
88
let(:subfields_from_774) { { 'w' => '991083840969706532', 't' => 'Seconde partie du discours aux Welches ' } }
99

0 commit comments

Comments
 (0)