diff options
-rw-r--r-- | actionmailer/CHANGELOG | 7 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/base.rb | 16 | ||||
-rwxr-xr-x | actionmailer/lib/action_mailer/vendor/tmail.rb | 1 | ||||
-rwxr-xr-x | actionmailer/test/mail_service_test.rb | 40 |
4 files changed, 56 insertions, 8 deletions
diff --git a/actionmailer/CHANGELOG b/actionmailer/CHANGELOG index b1195d84e9..bf0f2e8588 100644 --- a/actionmailer/CHANGELOG +++ b/actionmailer/CHANGELOG @@ -1,3 +1,10 @@ +*SVN* + +* Fixed that bcc and cc should be settable through @bcc and @cc -- not just @headers["Bcc"] and @headers["Cc"] #453 [Eric Hodel] + +* Fixed Action Mailer to be "warnings safe" so you can run with ruby -w and not get framework warnings #453 [Eric Hodel] + + *0.5* * Added access to custom headers, like cc, bcc, and reply-to #268 [Andreas Schwarz]. Example: diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 25dc6b2654..8390e70f4a 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -86,6 +86,7 @@ module ActionMailer #:nodoc: attr_accessor :recipients, :subject, :body, :from, :sent_on, :headers, :bcc, :cc def initialize + @bcc = @cc = @from = @recipients = @sent_on = @subject = @body = nil @headers = {} end @@ -147,15 +148,16 @@ module ActionMailer #:nodoc: mailer.body = {} mailer.send(method_name, *parameters) - if String === mailer.body - mail = create(mailer.recipients, mailer.subject, mailer.body, mailer.from, mailer.sent_on, mailer.headers) - else - mail = create(mailer.recipients, mailer.subject, render_body(mailer, method_name), mailer.from, mailer.sent_on, mailer.headers) + unless String === mailer.body then + mailer.body = render_body mailer, method_name end - mail.bcc = @bcc if @bcc - mail.cc = @cc if @cc - + mail = create(mailer.recipients, mailer.subject, mailer.body, + mailer.from, mailer.sent_on, mailer.headers) + + mail.bcc = mailer.bcc unless mailer.bcc.nil? + mail.cc = mailer.cc unless mailer.cc.nil? + return mail end diff --git a/actionmailer/lib/action_mailer/vendor/tmail.rb b/actionmailer/lib/action_mailer/vendor/tmail.rb index 013f3020c2..8cea88d3ed 100755 --- a/actionmailer/lib/action_mailer/vendor/tmail.rb +++ b/actionmailer/lib/action_mailer/vendor/tmail.rb @@ -1,4 +1,3 @@ require 'tmail/info' require 'tmail/mail' require 'tmail/mailbox' -require 'tmail/obsolete' diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index adc5be2fe9..2ad85b605c 100755 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -4,6 +4,7 @@ require 'test/unit' require 'action_mailer' class TestMailer < ActionMailer::Base + def signed_up(recipient) @recipients = recipient @subject = "[Signed up] Welcome #{recipient}" @@ -19,11 +20,23 @@ class TestMailer < ActionMailer::Base @sent_on = Time.local(2004, 12, 12) @body = "Goodbye, Mr. #{recipient}" end + + def cc_bcc(recipient) + @recipients = recipient + @subject = "testing bcc/cc" + @from = "system@loudthinking.com" + @sent_on = Time.local 2004, 12, 12 + @cc = "nobody@loudthinking.com" + @bcc = "root@loudthinking.com" + @body = "Nothing to see here." + end + end TestMailer.template_root = File.dirname(__FILE__) + "/fixtures" class ActionMailerTest < Test::Unit::TestCase + def setup ActionMailer::Base.delivery_method = :test ActionMailer::Base.perform_deliveries = true @@ -68,6 +81,31 @@ class ActionMailerTest < Test::Unit::TestCase assert_equal expected.encoded, ActionMailer::Base.deliveries.first.encoded end + def test_cc_bcc + expected = TMail::Mail.new + expected.to = @recipient + expected.subject = "testing bcc/cc" + expected.body = "Nothing to see here." + expected.from = "system@loudthinking.com" + expected.cc = "nobody@loudthinking.com" + expected.bcc = "root@loudthinking.com" + expected.date = Time.local 2004, 12, 12 + + created = nil + assert_nothing_raised do + created = TestMailer.create_cc_bcc @recipient + end + assert_not_nil created + assert_equal expected.encoded, created.encoded + + assert_nothing_raised do + TestMailer.deliver_cc_bcc @recipient + end + + assert_not_nil ActionMailer::Base.deliveries.first + assert_equal expected.encoded, ActionMailer::Base.deliveries.first.encoded + end + def test_instances_are_nil assert_nil ActionMailer::Base.new assert_nil TestMailer.new @@ -89,4 +127,6 @@ class ActionMailerTest < Test::Unit::TestCase TestMailer.deliver_signed_up(@recipient) assert_equal 1, ActionMailer::Base.deliveries.size end + end + |