diff options
author | Mikel Lindsaar <raasdnil@gmail.com> | 2010-01-27 00:06:19 +1100 |
---|---|---|
committer | Mikel Lindsaar <raasdnil@gmail.com> | 2010-01-27 00:06:19 +1100 |
commit | 9520166f70b84dd56640b7dbe8e3737c91e04bd9 (patch) | |
tree | bc1384f57119f85a86c4d79975909b295c47ba64 /actionmailer/test | |
parent | 9dd65c368b40093cfc686956a48c18b78abacf7f (diff) | |
download | rails-9520166f70b84dd56640b7dbe8e3737c91e04bd9.tar.gz rails-9520166f70b84dd56640b7dbe8e3737c91e04bd9.tar.bz2 rails-9520166f70b84dd56640b7dbe8e3737c91e04bd9.zip |
Fixed up being able to pass random headers in with headers, or mail. Also, undeprecated headers(hash) as this works now too
Diffstat (limited to 'actionmailer/test')
-rw-r--r-- | actionmailer/test/base_test.rb | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb index 7abdf7f4f8..9a39204998 100644 --- a/actionmailer/test/base_test.rb +++ b/actionmailer/test/base_test.rb @@ -5,15 +5,24 @@ class BaseTest < ActiveSupport::TestCase class BaseMailer < ActionMailer::Base self.mailer_name = "base_mailer" - self.defaults :to => 'system@test.lindsaar.net', - :from => 'jose@test.plataformatec.com', - :reply_to => 'mikel@test.lindsaar.net' + defaults({:to => 'system@test.lindsaar.net', + :from => 'jose@test.plataformatec.com', + :reply_to => 'mikel@test.lindsaar.net'}) def welcome(hash = {}) headers['X-SPAM'] = "Not SPAM" mail({:subject => "The first email on new API!"}.merge!(hash)) end + def simple(hash = {}) + mail(hash) + end + + def simple_with_headers(hash = {}) + headers hash + mail + end + def attachment_with_content(hash = {}) attachments['invoice.pdf'] = 'This is test File content' mail(hash) @@ -194,9 +203,9 @@ class BaseTest < ActiveSupport::TestCase end end - test "uses default headers from class" do + test "uses random default headers from class" do with_default BaseMailer, "X-SPAM" => "Not spam" do - email = BaseMailer.welcome.deliver + email = BaseMailer.simple assert_equal("Not spam", email["X-SPAM"].decoded) end end @@ -407,6 +416,22 @@ class BaseTest < ActiveSupport::TestCase mail = BaseMailer.explicit_multipart assert_not_nil(mail.content_type_parameters[:boundary]) end + + test "can pass random headers in as a hash" do + hash = {'X-Special-Domain-Specific-Header' => "SecretValue", + 'In-Reply-To' => '1234@mikel.me.com' } + mail = BaseMailer.simple_with_headers(hash) + assert_equal('SecretValue', mail['X-Special-Domain-Specific-Header'].decoded) + assert_equal('1234@mikel.me.com', mail['In-Reply-To'].decoded) + end + + test "can pass random headers in as a hash to mail" do + hash = {'X-Special-Domain-Specific-Header' => "SecretValue", + 'In-Reply-To' => '1234@mikel.me.com' } + mail = BaseMailer.simple(hash) + assert_equal('SecretValue', mail['X-Special-Domain-Specific-Header'].decoded) + assert_equal('1234@mikel.me.com', mail['In-Reply-To'].decoded) + end protected |