Permalink
Browse files

mailer can be anonymous

closes #5970
  • Loading branch information...
1 parent 7d67880 commit c17d200e3f1b86219c0e12809e93e8943dfa325a @lest committed May 13, 2012
@@ -3,6 +3,7 @@
require 'active_support/core_ext/object/blank'
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:
@@ -401,7 +402,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
@@ -610,6 +610,19 @@ def notify
assert_equal Set.new(["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 c17d200

Please sign in to comment.