Permalink
Browse files

Fix GH #4946. If we don't call mail method, the method implicitly is …

…called.
  • Loading branch information...
1 parent 6219beb commit acccb5c16c3ef7d6fb8db564397261e3dd5b1cad @kennyj committed Feb 12, 2012
@@ -446,7 +446,11 @@ def method_missing(method, *args) #:nodoc:
def initialize(method_name=nil, *args)
super()
@_message = Mail.new
- process(method_name, *args) if method_name
+ @rendered = false
+ if method_name
+ process(method_name, *args)
+ mail unless @rendered
+ end
end
def process(*args) #:nodoc:
@@ -640,7 +644,8 @@ def mail(headers={}, &block)
m.body.set_sort_order(parts_order)
m.body.sort_parts!
end
-
+
+ @rendered = true
m
end
@@ -89,6 +89,11 @@ def teardown
assert_equal('1234@mikel.me.com', mail['In-Reply-To'].decoded)
end
+ test "implicitly mail method call" do
+ mail = BaseMailer.dont_call_mail_method
+ assert mail.delivery_method.is_a?(Mail::TestMailer)
+ end
+
# Attachments
test "attachment with content" do
email = BaseMailer.attachment_with_content
@@ -2,6 +2,6 @@ class AssetMailer < ActionMailer::Base
self.mailer_name = "asset_mailer"
def welcome
- mail
+ mail
end
end
@@ -15,6 +15,10 @@ def welcome_with_headers(hash = {})
mail
end
+ def dont_call_mail_method(hash = {})
+ headers hash
+ end
+
def welcome_from_another_path(path)
mail(:template_name => "welcome", :template_path => path)
end

0 comments on commit acccb5c

Please sign in to comment.