diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-05-14 06:18:42 -0700 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-05-14 10:21:27 -0300 |
commit | 2506d4ad9e79532a0000ebd73baf0478db30f5c9 (patch) | |
tree | e77c2f11760eaac4dbebd7481db2c6009785e39f | |
parent | ec68258f19678d47acc6e5684c9dbc18a7382589 (diff) | |
download | rails-2506d4ad9e79532a0000ebd73baf0478db30f5c9.tar.gz rails-2506d4ad9e79532a0000ebd73baf0478db30f5c9.tar.bz2 rails-2506d4ad9e79532a0000ebd73baf0478db30f5c9.zip |
Merge pull request #6018 from lest/patch-1
mailer can be anonymous
-rw-r--r-- | actionmailer/lib/action_mailer/base.rb | 3 | ||||
-rw-r--r-- | actionmailer/test/base_test.rb | 13 | ||||
-rw-r--r-- | actionmailer/test/fixtures/anonymous/welcome.erb | 1 |
3 files changed, 16 insertions, 1 deletions
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 8f2c567e3e..2a11cb6ca7 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -5,6 +5,7 @@ require 'active_support/core_ext/object/blank' require 'active_support/core_ext/proc' require 'active_support/core_ext/string/inflections' require 'active_support/core_ext/hash/except' +require 'active_support/core_ext/module/anonymous' require 'action_mailer/log_subscriber' module ActionMailer #:nodoc: @@ -375,7 +376,7 @@ module ActionMailer #:nodoc: end def mailer_name - @mailer_name ||= name.underscore + @mailer_name ||= anonymous? ? "anonymous" : name.underscore end attr_writer :mailer_name alias :controller_path :mailer_name diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb index 9fdd0e1ced..d92fc01ef8 100644 --- a/actionmailer/test/base_test.rb +++ b/actionmailer/test/base_test.rb @@ -562,6 +562,19 @@ class BaseTest < ActiveSupport::TestCase assert_equal ["notify"], FooMailer.action_methods end + test "mailer can be anonymous" do + mailer = Class.new(ActionMailer::Base) do + def welcome + mail + end + end + + assert_equal "anonymous", mailer.mailer_name + + assert_equal "Welcome", mailer.welcome.subject + assert_equal "Anonymous mailer body", mailer.welcome.body.encoded.strip + end + protected # Execute the block setting the given values and restoring old values after diff --git a/actionmailer/test/fixtures/anonymous/welcome.erb b/actionmailer/test/fixtures/anonymous/welcome.erb new file mode 100644 index 0000000000..8361da62c4 --- /dev/null +++ b/actionmailer/test/fixtures/anonymous/welcome.erb @@ -0,0 +1 @@ +Anonymous mailer body |