aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/lib
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2012-09-28 12:11:48 +0100
committerJon Leighton <j@jonathanleighton.com>2012-09-28 12:13:07 +0100
commit7e0cf563639bc7508da381b1b8321c7a89be1aa8 (patch)
tree8523ada77bfb8630cdc88520b6ae65b78a1afb11 /actionmailer/lib
parentaa8918aecbc49f36faec4fa5d3d0efd7a4c9e889 (diff)
downloadrails-7e0cf563639bc7508da381b1b8321c7a89be1aa8.tar.gz
rails-7e0cf563639bc7508da381b1b8321c7a89be1aa8.tar.bz2
rails-7e0cf563639bc7508da381b1b8321c7a89be1aa8.zip
Support `Mailer.deliver_foo(*args)` as a synonym for `Mailer.foo(*args).deliver`.
This makes it easy to write e.g. `Mailer.expects(:deliver_foo)` when testing code that calls the mailer.
Diffstat (limited to 'actionmailer/lib')
-rw-r--r--actionmailer/lib/action_mailer/base.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb
index ff6911f44f..bd33f81f1e 100644
--- a/actionmailer/lib/action_mailer/base.rb
+++ b/actionmailer/lib/action_mailer/base.rb
@@ -142,6 +142,7 @@ module ActionMailer
# for delivery later:
#
# Notifier.welcome(david).deliver # sends the email
+ # Notifier.deliver_welcome(david) # synonym for the former
# mail = Notifier.welcome(david) # => a Mail::Message object
# mail.deliver # sends the email
#
@@ -487,6 +488,8 @@ module ActionMailer
def method_missing(method_name, *args)
if action_methods.include?(method_name.to_s)
QueuedMessage.new(queue, self, method_name, *args)
+ elsif method_name.to_s =~ /^deliver_(.+)$/ && action_methods.include?($1)
+ public_send($1, *args).deliver
else
super
end