提交 53b98f1d 编写于 作者: Y yuuji.yaginuma

Add `:args` to `process.action_mailer` event

上级 d13bc5df
* Add `:args` to `process.action_mailer` event.
*Yuji Yaginuma*
* Add parameterized invocation of mailers as a way to share before filters and defaults between actions.
See ActionMailer::Parameterized for a full example of the benefit.
......
......@@ -598,7 +598,8 @@ def initialize
def process(method_name, *args) #:nodoc:
payload = {
mailer: self.class.name,
action: method_name
action: method_name,
args: args
}
ActiveSupport::Notifications.instrument("process.action_mailer", payload) do
......
......@@ -834,6 +834,25 @@ def a_callback
assert_equal "special indeed!", mail["X-Special-Header"].to_s
end
test "notification for process" do
begin
events = []
ActiveSupport::Notifications.subscribe("process.action_mailer") do |*args|
events << ActiveSupport::Notifications::Event.new(*args)
end
BaseMailer.welcome(body: "Hello there").deliver_now
assert_equal 1, events.length
assert_equal "process.action_mailer", events[0].name
assert_equal "BaseMailer", events[0].payload[:mailer]
assert_equal :welcome, events[0].payload[:action]
assert_equal [{ body: "Hello there" }], events[0].payload[:args]
ensure
ActiveSupport::Notifications.unsubscribe "process.action_mailer"
end
end
private
# 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.
先完成此消息的编辑!
想要评论请 注册