From 9241fb801125ec0b6f56055b6499efa4f65c307c Mon Sep 17 00:00:00 2001 From: Jonathan Rochkind Date: Mon, 23 Feb 2015 17:07:57 -0500 Subject: [PATCH] Allowing Rails 4.2, removing deprecations for Rails 4.2 --- app/controllers/export_email_controller.rb | 4 ++-- app/controllers/feedback_controller.rb | 2 +- app/controllers/umlaut/controller_behavior.rb | 14 ++++++++++++++ lib/umlaut/version.rb | 2 +- test/dummy/config/environments/test.rb | 2 +- test/unit/feedback_mailer_test.rb | 4 ++-- 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/app/controllers/export_email_controller.rb b/app/controllers/export_email_controller.rb index 7a05d97e..bd22e26a 100644 --- a/app/controllers/export_email_controller.rb +++ b/app/controllers/export_email_controller.rb @@ -11,7 +11,7 @@ def send_email @fulltexts = @user_request.get_service_type('fulltext', { :refresh=>true }) @holdings = @user_request.get_service_type('holding', { :refresh=>true }) if valid_email? - Emailer.citation(@email, @user_request, @fulltexts, @holdings).deliver + action_mailer_deliver Emailer.citation(@email, @user_request, @fulltexts, @holdings) else flash[:alert] = email_validation_error render :email and return @@ -29,7 +29,7 @@ def send_txt @email = "#{@number}@#{@provider}" unless @number.nil? or @provider.nil? @holding = params[:holding] if valid_txt_number? && valid_txt_holding? - Emailer.short_citation(@email, @user_request, holding_location(@holding), call_number(@holding)).deliver + action_mailer_deliver Emailer.short_citation(@email, @user_request, holding_location(@holding), call_number(@holding)) else flash[:alert] = txt_validation_error render :txt and return diff --git a/app/controllers/feedback_controller.rb b/app/controllers/feedback_controller.rb index 50118810..6f44d3d9 100644 --- a/app/controllers/feedback_controller.rb +++ b/app/controllers/feedback_controller.rb @@ -15,7 +15,7 @@ def create ) end - FeedbackMailer.feedback(request.host_with_port, to_address, options).deliver + action_mailer_deliver FeedbackMailer.feedback(request.host_with_port, to_address, options) flash[:alert_success] = "Thanks, your message has been sent." diff --git a/app/controllers/umlaut/controller_behavior.rb b/app/controllers/umlaut/controller_behavior.rb index 34b54a04..124410da 100644 --- a/app/controllers/umlaut/controller_behavior.rb +++ b/app/controllers/umlaut/controller_behavior.rb @@ -87,6 +87,20 @@ def specified_service_groups(arg_params = params) end protected :specified_service_groups + # Call an ActionMailer::Base without deprecation warnings in Rails 4.3, + # but still work in earlier rails without deliver_later + # + # Calls with deliver_later in Rails 4.3. If no ActiveJob queue + # is set up, no problem default is immediate executor anyway. + def action_mailer_deliver(mailer) + if mailer.respond_to?(:deliver_later) + mailer.deliver_later + else + mailer.deliver + end + end + protected :action_mailer_deliver + end diff --git a/lib/umlaut/version.rb b/lib/umlaut/version.rb index 84f474d7..d0db4bb6 100644 --- a/lib/umlaut/version.rb +++ b/lib/umlaut/version.rb @@ -4,5 +4,5 @@ module Umlaut # This is used in Umlaut's .gemspec for generating the gem, # and is also used in the umlaut app generator to make sure # we're generating with a compatible Rails version. - RAILS_COMPAT_SPEC = [">= 3.2.12", "< 4.2.0"] + RAILS_COMPAT_SPEC = [">= 3.2.12", "< 4.3.0"] end diff --git a/test/dummy/config/environments/test.rb b/test/dummy/config/environments/test.rb index e487c825..bc6165ca 100644 --- a/test/dummy/config/environments/test.rb +++ b/test/dummy/config/environments/test.rb @@ -38,5 +38,5 @@ # Print deprecation notices to the stderr config.active_support.deprecation = :stderr - + config.active_support.test_order = :random end diff --git a/test/unit/feedback_mailer_test.rb b/test/unit/feedback_mailer_test.rb index f07cdf27..681710e7 100644 --- a/test/unit/feedback_mailer_test.rb +++ b/test/unit/feedback_mailer_test.rb @@ -17,7 +17,7 @@ class FeedbackMailerTest < ActionMailer::TestCase feedback_email = "joe@example.org" feedback_text = "This is my feedback, yes it is" - email = FeedbackMailer.feedback(@host, @to_email, :umlaut_request => umlaut_request, :name => feedback_name, :email => feedback_email, :feedback => feedback_text).deliver + email = FeedbackMailer.feedback(@host, @to_email, :umlaut_request => umlaut_request, :name => feedback_name, :email => feedback_email, :feedback => feedback_text).deliver_now assert ActionMailer::Base.deliveries.present? assert_equal [UmlautController.umlaut_config.from_email_addr], email.from @@ -48,7 +48,7 @@ class FeedbackMailerTest < ActionMailer::TestCase feedback_email = "joe@example.org" feedback_text = "This is my feedback, yes it is" - email = FeedbackMailer.feedback(@host, @to_email, :name => feedback_name, :email => feedback_email, :feedback => feedback_text).deliver + email = FeedbackMailer.feedback(@host, @to_email, :name => feedback_name, :email => feedback_email, :feedback => feedback_text).deliver_now # just no raise is good enough for this test for now, mostly assert_includes email.body, "No citation supplied"