diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2017-02-05 17:12:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-05 17:12:22 +0100 |
commit | b9ae7481fd5653fc6430148f06e0fca27317829e (patch) | |
tree | d4e8b3bb07b18ff6a05778d70c2eacd31c2fc516 /actionmailer | |
parent | 2cb6c27310452da11b93d729c3b760ce988106e1 (diff) | |
parent | 53b98f1ddabe5375ae92b014c41e2ef8a2606927 (diff) | |
download | rails-b9ae7481fd5653fc6430148f06e0fca27317829e.tar.gz rails-b9ae7481fd5653fc6430148f06e0fca27317829e.tar.bz2 rails-b9ae7481fd5653fc6430148f06e0fca27317829e.zip |
Merge pull request #27900 from y-yagi/add_arg_key_to_process_action_mailer_event
Add `:args` to `process.action_mailer` event.
Diffstat (limited to 'actionmailer')
-rw-r--r-- | actionmailer/CHANGELOG.md | 4 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/base.rb | 3 | ||||
-rw-r--r-- | actionmailer/test/base_test.rb | 19 |
3 files changed, 25 insertions, 1 deletions
diff --git a/actionmailer/CHANGELOG.md b/actionmailer/CHANGELOG.md index 54b07a626b..6ec10c7a70 100644 --- a/actionmailer/CHANGELOG.md +++ b/actionmailer/CHANGELOG.md @@ -1,3 +1,7 @@ +* 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. diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index f02108a859..444be944df 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -598,7 +598,8 @@ module ActionMailer 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 diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb index 490aaf33fc..61960d411d 100644 --- a/actionmailer/test/base_test.rb +++ b/actionmailer/test/base_test.rb @@ -834,6 +834,25 @@ class BaseTest < ActiveSupport::TestCase 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 |