aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/test/base_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionmailer/test/base_test.rb')
-rw-r--r--actionmailer/test/base_test.rb56
1 files changed, 43 insertions, 13 deletions
diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb
index 03e3f81acd..57bfe2375e 100644
--- a/actionmailer/test/base_test.rb
+++ b/actionmailer/test/base_test.rb
@@ -78,6 +78,23 @@ class BaseTest < ActiveSupport::TestCase
format.html{ render "welcome" } if include_html
end
end
+
+ def different_template(template_name='')
+ mail do |format|
+ format.text { render :template => template_name }
+ format.html { render :template => template_name }
+ end
+ end
+
+ def different_layout(layout_name='')
+ mail do |format|
+ format.text {
+ render :layout => layout_name
+ }
+ format.html { render :layout => layout_name }
+ end
+ end
+
end
test "method call to mail does not raise error" do
@@ -398,6 +415,21 @@ class BaseTest < ActiveSupport::TestCase
assert_equal("7bit", email.parts[1].content_transfer_encoding)
end
+ test "explicit multipart should be multipart" do
+ mail = BaseMailer.explicit_multipart
+ assert_not_nil(mail.content_type_parameters[:boundary])
+ end
+
+ test "should set a content type if only has an html part" do
+ mail = BaseMailer.html_only
+ assert_equal('text/html', mail.mime_type)
+ end
+
+ test "should set a content type if only has an plain text part" do
+ mail = BaseMailer.plain_text_only
+ assert_equal('text/plain', mail.mime_type)
+ end
+
test "explicit multipart with one part is rendered as body" do
email = BaseMailer.custom_block
assert_equal(0, email.parts.size)
@@ -439,20 +471,18 @@ class BaseTest < ActiveSupport::TestCase
BaseMailer.expects(:welcome).returns(mail)
BaseMailer.welcome.deliver
end
-
- test "explicit multipart should be multipart" do
- mail = BaseMailer.explicit_multipart
- assert_not_nil(mail.content_type_parameters[:boundary])
- end
-
- test "should set a content type if only has an html part" do
- mail = BaseMailer.html_only
- assert_equal('text/html', mail.mime_type)
+
+ # Rendering
+ test "that you can specify a different template" do
+ mail = BaseMailer.different_template('explicit_multipart_templates')
+ assert_equal("HTML Explicit Multipart Templates", mail.html_part.body.decoded)
+ assert_equal("TEXT Explicit Multipart Templates", mail.text_part.body.decoded)
end
-
- test "should set a content type if only has an plain text part" do
- mail = BaseMailer.plain_text_only
- assert_equal('text/plain', mail.mime_type)
+
+ test "that you can specify a different layout" do
+ mail = BaseMailer.different_layout('different_layout')
+ assert_equal("HTML -- HTML", mail.html_part.body.decoded)
+ assert_equal("PLAIN -- PLAIN", mail.text_part.body.decoded)
end
protected