From 05c4ad9d3f6ff8d0017f4bca9b52e552629c4813 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim=20and=20Mikel=20Lindsaar?= Date: Tue, 26 Jan 2010 16:00:24 +0100 Subject: Tidy up tests and docs. --- actionmailer/lib/action_mailer/base.rb | 4 ++-- actionmailer/test/base_test.rb | 37 +++++++++++++++++----------------- 2 files changed, 21 insertions(+), 20 deletions(-) (limited to 'actionmailer') diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 669e49c91c..b230e34631 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -360,8 +360,8 @@ module ActionMailer #:nodoc: # You can also pass a hash into headers of header field names and values, which # will then be set on the Mail::Message object: # - # headers {'X-Special-Domain-Specific-Header' => "SecretValue", - # 'In-Reply-To' => incoming.message_id } + # headers 'X-Special-Domain-Specific-Header' => "SecretValue", + # 'In-Reply-To' => incoming.message_id # # The resulting Mail::Message will have the following in it's header: # diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb index 0709c92326..4a65363e3e 100644 --- a/actionmailer/test/base_test.rb +++ b/actionmailer/test/base_test.rb @@ -79,7 +79,7 @@ class BaseTest < ActiveSupport::TestCase # Basic mail usage without block test "mail() should set the headers of the mail message" do email = BaseMailer.welcome - assert_equal(['system@test.lindsaar.net'], email.to) + assert_equal(['system@test.lindsaar.net'], email.to) assert_equal(['jose@test.plataformatec.com'], email.from) assert_equal('The first email on new API!', email.subject) end @@ -126,6 +126,22 @@ class BaseTest < ActiveSupport::TestCase assert_equal("Not SPAM", email['X-SPAM'].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 + + 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 + # Attachments test "attachment with content" do email = BaseMailer.attachment_with_content @@ -397,7 +413,8 @@ class BaseTest < ActiveSupport::TestCase test "calling deliver on the action should deliver the mail object" do BaseMailer.deliveries.clear BaseMailer.expects(:deliver_mail).once - BaseMailer.welcome.deliver + mail = BaseMailer.welcome.deliver + assert_instance_of Mail::Message, mail end test "calling deliver on the action should increment the deliveries collection" do @@ -417,22 +434,6 @@ 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 -- cgit v1.2.3