Skip to content

Commit 3e3e63c

Browse files
authored
Merge pull request #3576 from projectblacklight/remove-rails4
Remove code supporting Rails 4
2 parents 4405182 + 81e8190 commit 3e3e63c

File tree

2 files changed

+13
-22
lines changed

2 files changed

+13
-22
lines changed

app/controllers/concerns/blacklight/catalog.rb

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -235,22 +235,14 @@ def search_action_url options = {}
235235
# Email Action (this will render the appropriate view on GET requests and process the form and send the email on POST requests)
236236
def email_action documents
237237
mail = RecordMailer.email_record(documents, { to: params[:to], message: params[:message], config: blacklight_config }, url_options)
238-
if mail.respond_to? :deliver_now
239-
mail.deliver_now
240-
else
241-
mail.deliver
242-
end
238+
mail.deliver_now
243239
end
244240

245241
# SMS action (this will render the appropriate view on GET requests and process the form and send the email on POST requests)
246242
def sms_action documents
247243
to = "#{params[:to].gsub(/[^\d]/, '')}@#{params[:carrier]}"
248244
mail = RecordMailer.sms_record(documents, { to: to, config: blacklight_config }, url_options)
249-
if mail.respond_to? :deliver_now
250-
mail.deliver_now
251-
else
252-
mail.deliver
253-
end
245+
mail.deliver_now
254246
end
255247

256248
def validate_sms_params

spec/controllers/catalog_controller_spec.rb

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -499,13 +499,14 @@ def export_as_mock
499499
expect(request.flash[:error]).to be_nil
500500
end
501501

502-
it "redirects back to the record upon success" do
503-
allow(RecordMailer).to receive(:email_record)
504-
.with(anything, { to: '[email protected]', message: 'xyz', config: config }, hash_including(host: 'test.host'))
505-
.and_return double(deliver: nil)
506-
post :email, params: { id: doc_id, to: '[email protected]', message: 'xyz' }
507-
expect(request.flash[:error]).to be_nil
508-
expect(request).to redirect_to(solr_document_path(doc_id))
502+
context 'when message is provided' do
503+
it "sends email and redirects back to the record" do
504+
expect do
505+
post :email, params: { id: doc_id, to: '[email protected]', message: 'xyz' }
506+
end.to send_email(to: '[email protected]')
507+
expect(request.flash[:error]).to be_nil
508+
expect(request).to redirect_to(solr_document_path(doc_id))
509+
end
509510
end
510511

511512
it "renders email_success for XHR requests" do
@@ -549,11 +550,9 @@ def export_as_mock
549550
end
550551

551552
it "sends to the appropriate carrier email address" do
552-
expect(RecordMailer)
553-
.to receive(:sms_record)
554-
.with(anything, { to: '[email protected]', config: config }, hash_including(host: 'test.host'))
555-
.and_return double(deliver: nil)
556-
post :sms, params: { id: doc_id, to: '5555555555', carrier: 'txt.att.net' }
553+
expect do
554+
post :sms, params: { id: doc_id, to: '5555555555', carrier: 'txt.att.net' }
555+
end.to send_email(to: '[email protected]')
557556
end
558557

559558
it "redirects back to the record upon success" do

0 commit comments

Comments
 (0)