From 5c981528f20d53ad441b61c70350cc53fe3e8b6f Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Fri, 1 Jul 2005 20:43:40 +0000 Subject: Better multipart support with implicit multipart/alternative and sorting of subparts [John Long] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1586 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../implicitly_multipart_example.text.yaml.rhtml | 1 + actionmailer/test/mail_service_test.rb | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 actionmailer/test/fixtures/test_mailer/implicitly_multipart_example.text.yaml.rhtml (limited to 'actionmailer/test') diff --git a/actionmailer/test/fixtures/test_mailer/implicitly_multipart_example.text.yaml.rhtml b/actionmailer/test/fixtures/test_mailer/implicitly_multipart_example.text.yaml.rhtml new file mode 100644 index 0000000000..c14348c770 --- /dev/null +++ b/actionmailer/test/fixtures/test_mailer/implicitly_multipart_example.text.yaml.rhtml @@ -0,0 +1 @@ +yaml to: <%= @recipient %> \ No newline at end of file diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index 01b71801b8..85fe3ad69b 100755 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -111,12 +111,13 @@ class TestMailer < ActionMailer::Base :body => "123456789" end - def implicitly_multipart_example(recipient) + def implicitly_multipart_example(recipient, order = nil) @recipients = recipient @subject = "multipart example" @from = "test@example.com" @sent_on = Time.local 2004, 12, 12 @body = { "recipient" => recipient } + @implicit_parts_order = order unless order.nil? end def html_mail(recipient) @@ -551,11 +552,22 @@ EOF def test_implicitly_multipart_messages mail = TestMailer.create_implicitly_multipart_example(@recipient) - assert_equal 2, mail.parts.length - assert_equal "text/html", mail.parts[0].content_type + assert_equal 3, mail.parts.length + assert_equal "multipart/alternative", mail.content_type + assert_equal "text/yaml", mail.parts[0].content_type assert_equal "utf-8", mail.parts[0].sub_header("content-type", "charset") assert_equal "text/plain", mail.parts[1].content_type assert_equal "utf-8", mail.parts[1].sub_header("content-type", "charset") + assert_equal "text/html", mail.parts[2].content_type + assert_equal "utf-8", mail.parts[2].sub_header("content-type", "charset") + end + + def test_implicitly_multipart_messages_with_custom_order + mail = TestMailer.create_implicitly_multipart_example(@recipient, ["text/yaml", "text/plain"]) + assert_equal 3, mail.parts.length + assert_equal "text/html", mail.parts[0].content_type + assert_equal "text/plain", mail.parts[1].content_type + assert_equal "text/yaml", mail.parts[2].content_type end def test_html_mail -- cgit v1.2.3