]> source.dussan.org Git - redmine.git/commitdiff
Fixed that the mail method should return a Mail::Message (#15113).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 13 Oct 2013 07:58:33 +0000 (07:58 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 13 Oct 2013 07:58:33 +0000 (07:58 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@12210 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/mailer.rb
test/unit/mailer_test.rb

index c6822362e06f4171730f4025e3a9b8eb57613ad7..c6becfdd490f82a2e7691adc27fda7931df60482 100644 (file)
@@ -368,7 +368,7 @@ class Mailer < ActionMailer::Base
     ActionMailer::Base.delivery_method = saved_method
   end
 
-  def mail(headers={})
+  def mail(headers={}, &block)
     headers.merge! 'X-Mailer' => 'Redmine',
             'X-Redmine-Host' => Setting.host_name,
             'X-Redmine-Site' => Setting.app_title,
@@ -403,12 +403,17 @@ class Mailer < ActionMailer::Base
       headers[:references] = @references_objects.collect {|o| "<#{self.class.references_for(o)}>"}.join(' ')
     end
 
-    super headers do |format|
-      format.text
-      format.html unless Setting.plain_text_mail?
+    m = if block_given?
+      super headers, &block
+    else
+      super headers do |format|
+        format.text
+        format.html unless Setting.plain_text_mail?
+      end
     end
-
     set_language_if_valid @initial_language
+
+    m
   end
 
   def initialize(*args)
index a2f371632dd24e8333a3cd7e9487f3267eafd24a..138611bc13b9482c4934bfe900ba21a8940b18ed 100644 (file)
@@ -725,6 +725,10 @@ class MailerTest < ActiveSupport::TestCase
     end
   end
 
+  def test_mail_should_return_a_mail_message
+    assert_kind_of ::Mail::Message, Mailer.test_email(User.find(1))
+  end
+
   private
 
   def last_email