Permalink
Browse files

Merge pull request #6018 from lest/patch-1

mailer can be anonymous
  • Loading branch information...
carlosantoniodasilva committed May 14, 2012
1 parent ec68258 commit 2506d4ad9e79532a0000ebd73baf0478db30f5c9
@@ -5,6 +5,7 @@
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 @@ def register_interceptor(interceptor)
end
def mailer_name
- @mailer_name ||= name.underscore
+ @mailer_name ||= anonymous? ? "anonymous" : name.underscore
end
attr_writer :mailer_name
alias :controller_path :mailer_name
@@ -562,6 +562,19 @@ def notify
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
@@ -0,0 +1 @@
+Anonymous mailer body

0 comments on commit 2506d4a

Please sign in to comment.