aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer
diff options
context:
space:
mode:
authorYves Senn <yves.senn@garaio.com>2012-12-07 14:43:49 +0100
committerYves Senn <yves.senn@garaio.com>2012-12-10 09:10:47 +0100
commitec3429a3d6da2250f360d629fa6300e46f3d53fb (patch)
treeacda7dd44e33baf1d1043609f4773b1cb78b8e23 /actionmailer
parenta9dc44677ca0caa3660a54b191dca5229dc25f4f (diff)
downloadrails-ec3429a3d6da2250f360d629fa6300e46f3d53fb.tar.gz
rails-ec3429a3d6da2250f360d629fa6300e46f3d53fb.tar.bz2
rails-ec3429a3d6da2250f360d629fa6300e46f3d53fb.zip
The return value from mailer methods is not relevant.
Diffstat (limited to 'actionmailer')
-rw-r--r--actionmailer/CHANGELOG.md2
-rw-r--r--actionmailer/lib/action_mailer/base.rb5
-rw-r--r--actionmailer/test/base_test.rb6
-rw-r--r--actionmailer/test/mailers/base_mailer.rb5
4 files changed, 16 insertions, 2 deletions
diff --git a/actionmailer/CHANGELOG.md b/actionmailer/CHANGELOG.md
index af91907f46..6fc25b3bb4 100644
--- a/actionmailer/CHANGELOG.md
+++ b/actionmailer/CHANGELOG.md
@@ -2,7 +2,7 @@
* Explicit multipart messages no longer set the order of the MIME parts.
*Nate Berkopec*
-
+
* Do not render views when mail() isn't called.
Fix #7761
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb
index c9f10b359b..e4da975834 100644
--- a/actionmailer/lib/action_mailer/base.rb
+++ b/actionmailer/lib/action_mailer/base.rb
@@ -501,6 +501,7 @@ module ActionMailer
# 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
@@ -508,7 +509,8 @@ module ActionMailer
def process(*args) #:nodoc:
lookup_context.skip_default_locale!
- @_message = NullMail.new unless super
+ super
+ @_message = NullMail.new unless @_mail_was_called
end
class NullMail #:nodoc:
@@ -668,6 +670,7 @@ module ActionMailer
# end
#
def mail(headers={}, &block)
+ @_mail_was_called = true
m = @_message
# At the beginning, do not consider class default for parts order neither content_type
diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb
index 3c21886502..8d87d34e87 100644
--- a/actionmailer/test/base_test.rb
+++ b/actionmailer/test/base_test.rb
@@ -505,6 +505,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 52342bc59e..8fca6177bd 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