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

Conflicts:

	actionmailer/CHANGELOG.md
	actionmailer/lib/action_mailer/base.rb
This commit is contained in:
Yves Senn
2012-12-10 17:00:41 +01:00
parent d1b9c5fd11
commit 9b72c36783
4 changed files with 30 additions and 4 deletions

View File

@@ -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 File

@@ -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:

View File

@@ -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

View File

@@ -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