From 4ec7493e3cb9366df604f9f3082b4cd6f6dfd4fd Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Sat, 8 Dec 2012 10:20:59 -0500 Subject: use _action callbacks in actionmailer --- actionmailer/lib/action_mailer/base.rb | 8 +++--- actionmailer/test/base_test.rb | 20 +++++++-------- .../base_test/after_action_mailer/welcome.html.erb | 0 .../base_test/after_filter_mailer/welcome.html.erb | 0 .../before_action_mailer/welcome.html.erb | 0 .../before_filter_mailer/welcome.html.erb | 0 .../default_url_options_with_before_action_test.rb | 29 ++++++++++++++++++++++ .../default_url_options_with_filter_test.rb | 29 ---------------------- 8 files changed, 43 insertions(+), 43 deletions(-) create mode 100644 actionmailer/test/fixtures/base_test/after_action_mailer/welcome.html.erb delete mode 100644 actionmailer/test/fixtures/base_test/after_filter_mailer/welcome.html.erb create mode 100644 actionmailer/test/fixtures/base_test/before_action_mailer/welcome.html.erb delete mode 100644 actionmailer/test/fixtures/base_test/before_filter_mailer/welcome.html.erb create mode 100644 actionpack/test/controller/default_url_options_with_before_action_test.rb delete mode 100644 actionpack/test/controller/default_url_options_with_filter_test.rb diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 31005c9d9b..dcf13e927c 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -284,12 +284,12 @@ module ActionMailer # # = Callbacks # - # You can specify callbacks using before_filter and after_filter for configuring your messages. + # You can specify callbacks using before_action and after_action for configuring your messages. # This may be useful, for example, when you want to add default inline attachments for all # messages sent out by a certain mailer class: # # class Notifier < ActionMailer::Base - # before_filter :add_inline_attachment! + # before_action :add_inline_attachment! # # def welcome # mail @@ -306,8 +306,8 @@ module ActionMailer # can define and configure callbacks in the same manner that you would use callbacks in # classes that inherit from ActionController::Base. # - # Note that unless you have a specific reason to do so, you should prefer using before_filter - # rather than after_filter in your ActionMailer classes so that headers are parsed properly. + # Note that unless you have a specific reason to do so, you should prefer using before_action + # rather than after_action in your ActionMailer classes so that headers are parsed properly. # # = Configuration options # diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb index 3c21886502..4a608a9ad4 100644 --- a/actionmailer/test/base_test.rb +++ b/actionmailer/test/base_test.rb @@ -584,9 +584,9 @@ class BaseTest < ActiveSupport::TestCase assert_equal("Thanks for signing up this afternoon", mail.subject) end - test "modifying the mail message with a before_filter" do - class BeforeFilterMailer < ActionMailer::Base - before_filter :add_special_header! + test "modifying the mail message with a before_action" do + class BeforeActionMailer < ActionMailer::Base + before_action :add_special_header! def welcome ; mail ; end @@ -596,12 +596,12 @@ class BaseTest < ActiveSupport::TestCase end end - assert_equal('Wow, so special', BeforeFilterMailer.welcome['X-Special-Header'].to_s) + assert_equal('Wow, so special', BeforeActionMailer.welcome['X-Special-Header'].to_s) end - test "modifying the mail message with an after_filter" do - class AfterFilterMailer < ActionMailer::Base - after_filter :add_special_header! + test "modifying the mail message with an after_action" do + class AfterActionMailer < ActionMailer::Base + after_action :add_special_header! def welcome ; mail ; end @@ -611,12 +611,12 @@ class BaseTest < ActiveSupport::TestCase end end - assert_equal('Testing', AfterFilterMailer.welcome['X-Special-Header'].to_s) + assert_equal('Testing', AfterActionMailer.welcome['X-Special-Header'].to_s) end - test "adding an inline attachment using a before_filter" do + test "adding an inline attachment using a before_action" do class DefaultInlineAttachmentMailer < ActionMailer::Base - before_filter :add_inline_attachment! + before_action :add_inline_attachment! def welcome ; mail ; end diff --git a/actionmailer/test/fixtures/base_test/after_action_mailer/welcome.html.erb b/actionmailer/test/fixtures/base_test/after_action_mailer/welcome.html.erb new file mode 100644 index 0000000000..e69de29bb2 diff --git a/actionmailer/test/fixtures/base_test/after_filter_mailer/welcome.html.erb b/actionmailer/test/fixtures/base_test/after_filter_mailer/welcome.html.erb deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/actionmailer/test/fixtures/base_test/before_action_mailer/welcome.html.erb b/actionmailer/test/fixtures/base_test/before_action_mailer/welcome.html.erb new file mode 100644 index 0000000000..e69de29bb2 diff --git a/actionmailer/test/fixtures/base_test/before_filter_mailer/welcome.html.erb b/actionmailer/test/fixtures/base_test/before_filter_mailer/welcome.html.erb deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/actionpack/test/controller/default_url_options_with_before_action_test.rb b/actionpack/test/controller/default_url_options_with_before_action_test.rb new file mode 100644 index 0000000000..656fd0431e --- /dev/null +++ b/actionpack/test/controller/default_url_options_with_before_action_test.rb @@ -0,0 +1,29 @@ +require 'abstract_unit' + + +class ControllerWithBeforeActionAndDefaultUrlOptions < ActionController::Base + + before_action { I18n.locale = params[:locale] } + after_action { I18n.locale = "en" } + + def target + render :text => "final response" + end + + def redirect + redirect_to :action => "target" + end + + def default_url_options + {:locale => "de"} + end +end + +class ControllerWithBeforeActionAndDefaultUrlOptionsTest < ActionController::TestCase + + # This test has its roots in issue #1872 + test "should redirect with correct locale :de" do + get :redirect, :locale => "de" + assert_redirected_to "/controller_with_before_action_and_default_url_options/target?locale=de" + end +end diff --git a/actionpack/test/controller/default_url_options_with_filter_test.rb b/actionpack/test/controller/default_url_options_with_filter_test.rb deleted file mode 100644 index 9a9ab17fee..0000000000 --- a/actionpack/test/controller/default_url_options_with_filter_test.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'abstract_unit' - - -class ControllerWithBeforeFilterAndDefaultUrlOptions < ActionController::Base - - before_filter { I18n.locale = params[:locale] } - after_filter { I18n.locale = "en" } - - def target - render :text => "final response" - end - - def redirect - redirect_to :action => "target" - end - - def default_url_options - {:locale => "de"} - end -end - -class ControllerWithBeforeFilterAndDefaultUrlOptionsTest < ActionController::TestCase - - # This test has its roots in issue #1872 - test "should redirect with correct locale :de" do - get :redirect, :locale => "de" - assert_redirected_to "/controller_with_before_filter_and_default_url_options/target?locale=de" - end -end -- cgit v1.2.3