Skip to content

Commit

Permalink
Allowing Rails 4.2, removing deprecations for Rails 4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
jrochkind committed Feb 23, 2015
1 parent a025121 commit 9241fb8
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/controllers/export_email_controller.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/feedback_controller.rb
Expand Up @@ -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."

Expand Down
14 changes: 14 additions & 0 deletions app/controllers/umlaut/controller_behavior.rb
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/umlaut/version.rb
Expand Up @@ -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
2 changes: 1 addition & 1 deletion test/dummy/config/environments/test.rb
Expand Up @@ -38,5 +38,5 @@
# Print deprecation notices to the stderr
config.active_support.deprecation = :stderr


config.active_support.test_order = :random
end
4 changes: 2 additions & 2 deletions test/unit/feedback_mailer_test.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 9241fb8

Please sign in to comment.