Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Backport #8450, the return value from mailer methods is not relevant.

Conflicts:

	actionmailer/CHANGELOG.md
	actionmailer/lib/action_mailer/base.rb
  • Loading branch information...
commit 9b72c36783516f5ef8f2fac5f6f342a6a48d8d78 1 parent d1b9c5f
@senny authored
View
16 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.
View
7 actionmailer/lib/action_mailer/base.rb
@@ -448,6 +448,7 @@ def method_missing(method, *args) #: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 @@ def initialize(method_name=nil, *args)
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:
View
6 actionmailer/test/base_test.rb
@@ -477,6 +477,12 @@ def teardown
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
View
5 actionmailer/test/mailers/base_mailer.rb
@@ -118,4 +118,9 @@ def email_with_translations
def without_mail_call
end
+
+ def with_nil_as_return_value(hash = {})
+ mail(:template_name => "welcome")
+ nil
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.