aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer
diff options
context:
space:
mode:
Diffstat (limited to 'actionmailer')
-rw-r--r--actionmailer/CHANGELOG.md16
-rw-r--r--actionmailer/lib/action_mailer/base.rb7
-rw-r--r--actionmailer/test/base_test.rb6
-rw-r--r--actionmailer/test/mailers/base_mailer.rb5
4 files changed, 30 insertions, 4 deletions
diff --git a/actionmailer/CHANGELOG.md b/actionmailer/CHANGELOG.md
index 1005516f42..d4d592a964 100644
--- a/actionmailer/CHANGELOG.md
+++ b/actionmailer/CHANGELOG.md
@@ -1,5 +1,21 @@
## Rails 3.2.10 (unreleased) ##
+* The return value from mailer methods is no longer relevant. This fixes a bug,
+ which was introduced with 3.2.9.
+ Backport #8450
+ Fix #8448
+
+ class ExampleMailer < ActionMailer::Base
+ # in 3.2.9, returning a falsy value from a mailer action, prevented the email from beeing sent.
+ # With 3.2.10 the return value is no longer relevant. If you call mail() the email will be sent.
+ def nil_returning_mailer_action
+ mail()
+ nil
+ end
+ end
+
+ *Yves Senn*
+
## Rails 3.2.9 (Nov 12, 2012) ##
* Do not render views when mail() isn't called.
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb
index 1aeeadcacc..9e2f640915 100644
--- a/actionmailer/lib/action_mailer/base.rb
+++ b/actionmailer/lib/action_mailer/base.rb
@@ -448,6 +448,7 @@ module ActionMailer #:nodoc:
# method, for instance).
def initialize(method_name=nil, *args)
super()
+ @mail_was_called = false
@_message = Mail.new
process(method_name, *args) if method_name
end
@@ -455,10 +456,8 @@ module ActionMailer #:nodoc:
def process(*args) #:nodoc:
lookup_context.skip_default_locale!
- generated_mail = super
- unless generated_mail
- @_message = NullMail.new
- end
+ super
+ @_message = NullMail.new unless @mail_was_called
end
class NullMail #:nodoc:
diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb
index b69b26faf0..f648cb1546 100644
--- a/actionmailer/test/base_test.rb
+++ b/actionmailer/test/base_test.rb
@@ -477,6 +477,12 @@ class BaseTest < ActiveSupport::TestCase
mail.deliver
end
+ test 'the return value of mailer methods is not relevant' do
+ mail = BaseMailer.with_nil_as_return_value
+ assert_equal('Welcome', mail.body.to_s.strip)
+ mail.deliver
+ end
+
# Before and After hooks
class MyObserver
diff --git a/actionmailer/test/mailers/base_mailer.rb b/actionmailer/test/mailers/base_mailer.rb
index 8c4430b046..50438ead2a 100644
--- a/actionmailer/test/mailers/base_mailer.rb
+++ b/actionmailer/test/mailers/base_mailer.rb
@@ -118,4 +118,9 @@ class BaseMailer < ActionMailer::Base
def without_mail_call
end
+
+ def with_nil_as_return_value(hash = {})
+ mail(:template_name => "welcome")
+ nil
+ end
end