提交 c17d200e 编写于 作者: S Sergey Nartimov

mailer can be anonymous

closes #5970
上级 7d67880a
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册