Permalink
Browse files

The return value from mailer methods is not relevant.

  • Loading branch information...
1 parent a9dc446 commit ec3429a3d6da2250f360d629fa6300e46f3d53fb @senny committed Dec 7, 2012
@@ -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
@@ -501,14 +501,16 @@ def method_missing(method_name, *args)
# 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
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 @@ def attachments
# 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
@@ -505,6 +505,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
@@ -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

0 comments on commit ec3429a

Please sign in to comment.