mirror of
https://github.com/github/rails.git
synced 2026-01-09 14:48:08 -05:00
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:
@@ -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.
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user