Tidy up tests and docs.

上级 ccea6ab0
...@@ -360,8 +360,8 @@ def initialize(method_name=nil, *args) ...@@ -360,8 +360,8 @@ def initialize(method_name=nil, *args)
# You can also pass a hash into headers of header field names and values, which # You can also pass a hash into headers of header field names and values, which
# will then be set on the Mail::Message object: # will then be set on the Mail::Message object:
# #
# headers {'X-Special-Domain-Specific-Header' => "SecretValue", # headers 'X-Special-Domain-Specific-Header' => "SecretValue",
# 'In-Reply-To' => incoming.message_id } # 'In-Reply-To' => incoming.message_id
# #
# The resulting Mail::Message will have the following in it's header: # The resulting Mail::Message will have the following in it's header:
# #
......
...@@ -79,7 +79,7 @@ def custom_block(include_html=false) ...@@ -79,7 +79,7 @@ def custom_block(include_html=false)
# Basic mail usage without block # Basic mail usage without block
test "mail() should set the headers of the mail message" do test "mail() should set the headers of the mail message" do
email = BaseMailer.welcome 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(['jose@test.plataformatec.com'], email.from)
assert_equal('The first email on new API!', email.subject) assert_equal('The first email on new API!', email.subject)
end end
...@@ -126,6 +126,22 @@ def custom_block(include_html=false) ...@@ -126,6 +126,22 @@ def custom_block(include_html=false)
assert_equal("Not SPAM", email['X-SPAM'].decoded) assert_equal("Not SPAM", email['X-SPAM'].decoded)
end 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 # Attachments
test "attachment with content" do test "attachment with content" do
email = BaseMailer.attachment_with_content email = BaseMailer.attachment_with_content
...@@ -397,7 +413,8 @@ def custom_block(include_html=false) ...@@ -397,7 +413,8 @@ def custom_block(include_html=false)
test "calling deliver on the action should deliver the mail object" do test "calling deliver on the action should deliver the mail object" do
BaseMailer.deliveries.clear BaseMailer.deliveries.clear
BaseMailer.expects(:deliver_mail).once BaseMailer.expects(:deliver_mail).once
BaseMailer.welcome.deliver mail = BaseMailer.welcome.deliver
assert_instance_of Mail::Message, mail
end end
test "calling deliver on the action should increment the deliveries collection" do test "calling deliver on the action should increment the deliveries collection" do
...@@ -417,22 +434,6 @@ def custom_block(include_html=false) ...@@ -417,22 +434,6 @@ def custom_block(include_html=false)
mail = BaseMailer.explicit_multipart mail = BaseMailer.explicit_multipart
assert_not_nil(mail.content_type_parameters[:boundary]) assert_not_nil(mail.content_type_parameters[:boundary])
end 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 protected
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册