Skip to content

Commit e7ba689

Browse files
author
David Zuckerman
committed
rubocop fixes
1 parent ebc8222 commit e7ba689

5 files changed

Lines changed: 109 additions & 125 deletions

spec/jobs/bibliographic_job_spec.rb

Lines changed: 52 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -35,60 +35,56 @@
3535

3636
end
3737

38-
describe 'email notifications' do
39-
let(:mailer_double) { instance_double(ActionMailer::MessageDelivery, deliver_now: true) }
40-
41-
context 'when job succeeds' do
42-
it 'sends completion email with attachments' do
43-
fake_attachments = {
44-
"fake_completed.csv" => { mime_type: 'text/csv', content: 'csvdata' }
45-
}
46-
47-
allow_any_instance_of(BibliographicJob)
48-
.to receive(:generate_attatchments)
49-
.and_return(fake_attachments)
50-
51-
expect(RequestMailer)
52-
.to receive(:bibliographic_email)
53-
.with(
54-
email,
55-
fake_attachments,
56-
'Host Bibliographic Upload - Completed',
57-
'When there is an attached log file, please review unusual MMS ID information.'
58-
)
59-
.and_return(mailer_double)
60-
61-
BibliographicJob.perform_now(host_bib_task)
62-
63-
expect(host_bib_task.reload.status).to eq('succeeded')
64-
end
65-
end
66-
67-
context 'when job fails' do
68-
it 'sends failure email' do
69-
host_bib = host_bib_task.host_bibs.create(mms_id: mms_id1, marc_status: 'pending')
70-
71-
allow(Bibliographic::HostBib)
72-
.to receive(:create_linked_bibs)
73-
.with(host_bib)
74-
.and_raise(StandardError.new('Error'))
75-
76-
expect(RequestMailer)
77-
.to receive(:bibliographic_email)
78-
.with(
79-
email,
80-
[],
81-
'Host Bibliographic Upload - Failed',
82-
'Host Bibliographic upload failed, please reach out to our support team.'
83-
)
84-
.and_return(mailer_double)
85-
86-
expect {
87-
BibliographicJob.perform_now(host_bib_task)
88-
}.to raise_error(StandardError)
89-
90-
expect(host_bib_task.reload.status).to eq('failed')
91-
end
92-
end
93-
end
38+
describe 'email notifications' do
39+
let(:mailer_double) { instance_double(ActionMailer::MessageDelivery, deliver_now: true) }
40+
41+
context 'when job succeeds' do
42+
it 'sends completion email with attachments' do
43+
fake_attachments = {
44+
'fake_completed.csv' => { mime_type: 'text/csv', content: 'csvdata' }
45+
}
46+
47+
allow_any_instance_of(BibliographicJob)
48+
.to receive(:generate_attatchments)
49+
.and_return(fake_attachments)
50+
51+
expect(RequestMailer)
52+
.to receive(:bibliographic_email)
53+
.with(
54+
email,
55+
fake_attachments,
56+
'Host Bibliographic Upload - Completed',
57+
'When there is an attached log file, please review unusual MMS ID information.'
58+
).and_return(mailer_double)
59+
60+
BibliographicJob.perform_now(host_bib_task)
61+
62+
expect(host_bib_task.reload.status).to eq('succeeded')
63+
end
64+
end
65+
66+
context 'when job fails' do
67+
it 'sends failure email' do
68+
host_bib = host_bib_task.host_bibs.create(mms_id: mms_id1, marc_status: 'pending')
69+
70+
allow(Bibliographic::HostBib)
71+
.to receive(:create_linked_bibs)
72+
.with(host_bib)
73+
.and_raise(StandardError.new('Error'))
74+
75+
expect(RequestMailer)
76+
.to receive(:bibliographic_email)
77+
.with(
78+
email,
79+
[],
80+
'Host Bibliographic Upload - Failed',
81+
'Host Bibliographic upload failed, please reach out to our support team.'
82+
).and_return(mailer_double)
83+
84+
expect { BibliographicJob.perform_now(host_bib_task) }.to raise_error(StandardError)
85+
86+
expect(host_bib_task.reload.status).to eq('failed')
87+
end
88+
end
89+
end
9490
end

spec/jobs/patron_note_job_base_spec.rb

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@
6868

6969
expect(job).to receive(:log_error).at_least(:once)
7070

71-
expect {
72-
job.perform(patron_id)
73-
}.to raise_error(StandardError)
71+
expect { job.perform(patron_id) }.to raise_error(StandardError)
7472
end
7573
end
7674

@@ -91,17 +89,13 @@
9189
)
9290
.and_return(mail_double)
9391

94-
expect {
95-
job.perform(patron_id)
96-
}.to raise_error(StandardError)
92+
expect { job.perform(patron_id) }.to raise_error(StandardError)
9793
end
9894

9995
it 'logs error' do
10096
expect(job).to receive(:log_error).at_least(:once)
10197

102-
expect {
103-
job.perform(patron_id)
104-
}.to raise_error(StandardError)
98+
expect { job.perform(patron_id) }.to raise_error(StandardError)
10599
end
106100
end
107101

@@ -113,9 +107,7 @@
113107

114108
expect(job).to receive(:log_error).at_least(:once)
115109

116-
expect {
117-
job.perform(patron_id)
118-
}.to raise_error(StandardError)
110+
expect { job.perform(patron_id) }.to raise_error(StandardError)
119111
end
120112
end
121113

@@ -128,9 +120,7 @@
128120
it 'logs and raises error' do
129121
expect(job).to receive(:log_error).at_least(:once)
130122

131-
expect {
132-
job.perform(patron_id)
133-
}.to raise_error(StandardError)
123+
expect { job.perform(patron_id) }.to raise_error(StandardError)
134124
end
135125
end
136126
end

spec/request/proxy_borrower_forms_request_spec.rb

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -188,46 +188,46 @@
188188
date_term: '',
189189
renewal: ''
190190
} })
191-
191+
192192
expect(response).to have_http_status :unprocessable_entity
193193
expect(response.body).to match(/Please correct these and resubmit the form/)
194194
end
195195

196-
it 'submission enqueues confirmation + alert emails' do
197-
expect {
198-
post(forms_proxy_borrower_request_dsp_path, params: {
199-
proxy_borrower_requests: {
200-
student_name: 'Veronica Names',
201-
dsp_rep: 'DSP Rep',
202-
research_last: 'last',
203-
research_first: 'first',
204-
date_term: Date.tomorrow,
205-
renewal: 0
206-
}
207-
})
208-
}.to have_enqueued_job(ActionMailer::MailDeliveryJob).exactly(2).times
209-
210-
expect(response).to have_http_status(:created)
211-
end
212-
213-
it 'Faculty submission enqueues confirmation + alert emails' do
214-
allow_any_instance_of(User).to receive(:ucb_faculty?).and_return(true)
215-
216-
expect {
217-
post(forms_proxy_borrower_request_faculty_path, params: {
218-
proxy_borrower_requests: {
219-
faculty_name: 'Thelonius Monk',
220-
department: 'History',
221-
research_last: 'Last',
222-
research_first: 'First',
223-
date_term: Date.tomorrow,
224-
renewal: 0
225-
}
226-
})
227-
}.to have_enqueued_job(ActionMailer::MailDeliveryJob).exactly(2).times
228-
229-
expect(response).to have_http_status(:created)
230-
end
196+
it 'submission enqueues confirmation + alert emails' do
197+
expect do
198+
post(forms_proxy_borrower_request_dsp_path, params: {
199+
proxy_borrower_requests: {
200+
student_name: 'Veronica Names',
201+
dsp_rep: 'DSP Rep',
202+
research_last: 'last',
203+
research_first: 'first',
204+
date_term: Date.tomorrow,
205+
renewal: 0
206+
}
207+
})
208+
end.to have_enqueued_job(ActionMailer::MailDeliveryJob).exactly(2).times
209+
210+
expect(response).to have_http_status(:created)
211+
end
212+
213+
it 'Faculty submission enqueues confirmation + alert emails' do
214+
allow_any_instance_of(User).to receive(:ucb_faculty?).and_return(true)
215+
216+
expect do
217+
post(forms_proxy_borrower_request_faculty_path, params: {
218+
proxy_borrower_requests: {
219+
faculty_name: 'Thelonius Monk',
220+
department: 'History',
221+
research_last: 'Last',
222+
research_first: 'First',
223+
date_term: Date.tomorrow,
224+
renewal: 0
225+
}
226+
})
227+
end.to have_enqueued_job(ActionMailer::MailDeliveryJob).exactly(2).times
228+
229+
expect(response).to have_http_status(:created)
230+
end
231231

232232
end
233233
end

spec/request/reference_card_forms_request_spec.rb

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@
6262
}
6363
}
6464

65-
expect {
66-
post('/forms/reference-card', params:)
67-
}.to have_enqueued_job(ActionMailer::MailDeliveryJob)
65+
expect { post('/forms/reference-card', params:) }.to have_enqueued_job(ActionMailer::MailDeliveryJob)
6866

6967
expect(response).to have_http_status :created
7068
end
@@ -133,13 +131,13 @@
133131
pass_date_end: Date.current + 1,
134132
local_id: '8675309')
135133

136-
expect {
134+
expect do
137135
patch("/forms/reference-card/#{form.id}", params: {
138-
'stack_pass_[approve_deny]' => false,
139-
'processed_by' => 'ADMIN USER',
140-
'denial_reason' => 'Item listed at another library'
141-
})
142-
}.to have_enqueued_job(ActionMailer::MailDeliveryJob)
136+
'stack_pass_[approve_deny]' => false,
137+
'processed_by' => 'ADMIN USER',
138+
'denial_reason' => 'Item listed at another library'
139+
})
140+
end.to have_enqueued_job(ActionMailer::MailDeliveryJob)
143141

144142
expect(response).to redirect_to(action: :show, id: form.id)
145143

@@ -155,12 +153,12 @@
155153
pass_date_end: Date.current + 1,
156154
local_id: '8675309')
157155

158-
expect {
156+
expect do
159157
patch("/forms/reference-card/#{form.id}", params: {
160-
'stack_pass_[approve_deny]' => true,
161-
'processed_by' => 'ADMIN USER'
162-
})
163-
}.to have_enqueued_job(ActionMailer::MailDeliveryJob)
158+
'stack_pass_[approve_deny]' => true,
159+
'processed_by' => 'ADMIN USER'
160+
})
161+
end.to have_enqueued_job(ActionMailer::MailDeliveryJob)
164162
end
165163
end
166164
end

spec/request/stack_pass_form_request_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@
9898
phone: '925-555-1234', pass_date: Date.current + 1,
9999
main_stack: true, local_id: '8675309')
100100

101-
expect {
101+
expect do
102102
patch "/forms/stack-pass/#{form.id}", params: {
103103
stack_pass_: { approve_deny: false },
104104
processed_by: 'ADMIN USER',
105105
denial_reason: 'Item listed at another library'
106106
}
107-
}.to have_enqueued_job(ActionMailer::MailDeliveryJob)
107+
end.to have_enqueued_job(ActionMailer::MailDeliveryJob)
108108

109109
expect(response).to redirect_to(action: :show, id: form.id)
110110

@@ -118,12 +118,12 @@
118118
phone: '510-222-2222', pass_date: Date.current + 1,
119119
main_stack: true, local_id: '8675309')
120120

121-
expect {
121+
expect do
122122
patch "/forms/stack-pass/#{form.id}", params: {
123123
stack_pass_: { approve_deny: true },
124124
processed_by: 'ADMIN USER'
125125
}
126-
}.to have_enqueued_job(ActionMailer::MailDeliveryJob)
126+
end.to have_enqueued_job(ActionMailer::MailDeliveryJob)
127127
end
128128
end
129129

0 commit comments

Comments
 (0)