Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #6018 from lest/patch-1

mailer can be anonymous
  • Loading branch information...
commit 2506d4ad9e79532a0000ebd73baf0478db30f5c9 1 parent ec68258
@carlosantoniodasilva carlosantoniodasilva authored
View
3  actionmailer/lib/action_mailer/base.rb
@@ -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
View
13 actionmailer/test/base_test.rb
@@ -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
View
1  actionmailer/test/fixtures/anonymous/welcome.erb
@@ -0,0 +1 @@
+Anonymous mailer body
Please sign in to comment.
Something went wrong with that request. Please try again.