aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikel Lindsaar <raasdnil@gmail.com>2010-01-28 00:24:30 +1100
committerMikel Lindsaar <raasdnil@gmail.com>2010-01-28 00:24:30 +1100
commitb6b3db6734af8d5b42c7bdcea7c73923a5b88463 (patch)
tree87ea66957fcf45af72f5494e9ea8dd06343d8184
parentf3caa63bcbbfff093efcdfa3547fb2eb96479f0a (diff)
downloadrails-b6b3db6734af8d5b42c7bdcea7c73923a5b88463.tar.gz
rails-b6b3db6734af8d5b42c7bdcea7c73923a5b88463.tar.bz2
rails-b6b3db6734af8d5b42c7bdcea7c73923a5b88463.zip
Fixed bug on HTML only emails getting set to text/plain
-rw-r--r--actionmailer/lib/action_mailer/base.rb2
-rw-r--r--actionmailer/test/base_test.rb18
-rw-r--r--actionmailer/test/fixtures/base_mailer/html_only.html.erb1
-rw-r--r--actionmailer/test/fixtures/base_mailer/plain_text_only.text.erb1
4 files changed, 21 insertions, 1 deletions
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb
index 2288a30691..3fbf004a0d 100644
--- a/actionmailer/lib/action_mailer/base.rb
+++ b/actionmailer/lib/action_mailer/base.rb
@@ -531,7 +531,7 @@ module ActionMailer #:nodoc:
when m.multipart?
["multipart", "alternative", params]
else
- class_default
+ m.content_type || class_default
end
end
diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb
index 4a65363e3e..b7af86b622 100644
--- a/actionmailer/test/base_test.rb
+++ b/actionmailer/test/base_test.rb
@@ -17,6 +17,14 @@ class BaseTest < ActiveSupport::TestCase
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 @@ class BaseTest < ActiveSupport::TestCase
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
diff --git a/actionmailer/test/fixtures/base_mailer/html_only.html.erb b/actionmailer/test/fixtures/base_mailer/html_only.html.erb
new file mode 100644
index 0000000000..9c99a008e7
--- /dev/null
+++ b/actionmailer/test/fixtures/base_mailer/html_only.html.erb
@@ -0,0 +1 @@
+<h1>Testing</h1> \ No newline at end of file
diff --git a/actionmailer/test/fixtures/base_mailer/plain_text_only.text.erb b/actionmailer/test/fixtures/base_mailer/plain_text_only.text.erb
new file mode 100644
index 0000000000..0a90125685
--- /dev/null
+++ b/actionmailer/test/fixtures/base_mailer/plain_text_only.text.erb
@@ -0,0 +1 @@
+Testing \ No newline at end of file