Permalink
Browse files

mailer can be anonymous

closes #5970
  • Loading branch information...
lest committed May 13, 2012
1 parent 7d67880 commit c17d200e3f1b86219c0e12809e93e8943dfa325a
@@ -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

1 comment on commit c17d200

@exviva

This comment has been minimized.

Show comment Hide comment
@exviva

exviva May 14, 2012

Contributor

👍

Contributor

exviva commented on c17d200 May 14, 2012

👍

Please sign in to comment.