Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed bug on HTML only emails getting set to text/plain

  • Loading branch information...
commit b6b3db6734af8d5b42c7bdcea7c73923a5b88463 1 parent f3caa63
@mikel mikel authored
View
2  actionmailer/lib/action_mailer/base.rb
@@ -531,7 +531,7 @@ def set_content_type(m, user_content_type, class_default)
when m.multipart?
["multipart", "alternative", params]
else
- class_default
+ m.content_type || class_default
end
end
View
18 actionmailer/test/base_test.rb
@@ -17,6 +17,14 @@ def welcome(hash = {})
def simple(hash = {})
mail(hash)
end
+
+ def html_only(hash = {})
+ mail(hash)
+ end
+
+ def plain_text_only(hash = {})
+ mail(hash)
+ end
def simple_with_headers(hash = {})
headers hash
@@ -434,6 +442,16 @@ def custom_block(include_html=false)
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
protected
View
1  actionmailer/test/fixtures/base_mailer/html_only.html.erb
@@ -0,0 +1 @@
+<h1>Testing</h1>
View
1  actionmailer/test/fixtures/base_mailer/plain_text_only.text.erb
@@ -0,0 +1 @@
+Testing
Please sign in to comment.
Something went wrong with that request. Please try again.