diff options
Diffstat (limited to 'actionmailer/test/mail_service_test.rb')
-rw-r--r-- | actionmailer/test/mail_service_test.rb | 294 |
1 files changed, 182 insertions, 112 deletions
diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index c98f0a7601..9be9a93fef 100644 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -143,7 +143,7 @@ class TestMailer < ActionMailer::Base p.body = "blah" end - attachment :content_type => "image/jpeg", :filename => "foo.jpg", + attachment :content_type => "image/jpeg", :filename => File.join(File.dirname(__FILE__), "fixtures", "attachments", "foo.jpg"), :body => "123456789" render :text => "plain text default" @@ -232,7 +232,7 @@ class TestMailer < ActionMailer::Base p.part :content_type => "text/html", :body => "<b>test</b> HTML<br/>\nline #2" end - attachment :content_type => "application/octet-stream",:filename => "test.txt", :body => "test abcdefghijklmnopqstuvwxyz" + attachment :content_type => "application/octet-stream", :filename => "test.txt", :body => "test abcdefghijklmnopqstuvwxyz" end def nested_multipart_with_body(recipient) @@ -251,8 +251,8 @@ class TestMailer < ActionMailer::Base subject "custom header in attachment" from "test@example.com" content_type "multipart/related" - part :content_type => "text/html", :body => 'yo' - attachment :content_type => "image/jpeg",:filename => "test.jpeg", :body => "i am not a real picture", :headers => { 'Content-ID' => '<test@test.com>' } + part :content_type => "text/html", :body => 'yo' + attachment :content_type => "image/jpeg", :filename => File.join(File.dirname(__FILE__), "fixtures", "attachments", "test.jpg"), :body => "i am not a real picture", :headers => { 'Content-ID' => '<test@test.com>' } end def unnamed_attachment(recipient) @@ -319,10 +319,10 @@ class ActionMailerTest < Test::Unit::TestCase end def new_mail( charset="utf-8" ) - mail = TMail::Mail.new + mail = Mail.new mail.mime_version = "1.0" if charset - mail.set_content_type "text", "plain", { "charset" => charset } + mail.content_type ["text", "plain", { "charset" => charset }] end mail end @@ -346,30 +346,33 @@ class ActionMailerTest < Test::Unit::TestCase def test_nested_parts created = nil assert_nothing_raised { created = TestMailer.create_nested_multipart(@recipient)} - assert_equal 2,created.parts.size - assert_equal 2,created.parts.first.parts.size - - assert_equal "multipart/mixed", created.content_type - assert_equal "multipart/alternative", created.parts.first.content_type - assert_equal "bar", created.parts.first.header['foo'].to_s - assert_nil created.parts.first.charset - assert_equal "text/plain", created.parts.first.parts.first.content_type - assert_equal "text/html", created.parts.first.parts[1].content_type - assert_equal "application/octet-stream", created.parts[1].content_type + assert_equal 2, created.parts.size + assert_equal 2, created.parts.first.parts.size + + assert_equal "multipart/mixed", created.content_type.string + assert_equal "multipart/alternative", created.parts[0].content_type.string + assert_equal "bar", created.parts[0].header['foo'].decoded + assert_nil created.parts[0].charset + assert_equal "text/plain", created.parts[0].parts[0].content_type.string + assert_equal "text/html", created.parts[0].parts[1].content_type.string + assert_equal "application/octet-stream", created.parts[1].content_type.string + end def test_nested_parts_with_body created = nil TestMailer.create_nested_multipart_with_body(@recipient) assert_nothing_raised { created = TestMailer.create_nested_multipart_with_body(@recipient)} + assert_equal 1,created.parts.size assert_equal 2,created.parts.first.parts.size - assert_equal "multipart/mixed", created.content_type - assert_equal "multipart/alternative", created.parts.first.content_type - assert_equal "Nothing to see here.", created.parts.first.parts.first.body - assert_equal "text/plain", created.parts.first.parts.first.content_type - assert_equal "text/html", created.parts.first.parts[1].content_type + assert_equal "multipart/mixed", created.content_type.string + assert_equal "multipart/alternative", created.parts.first.content_type.string + assert_equal "text/plain", created.parts.first.parts.first.content_type.string + assert_equal "Nothing to see here.", created.parts.first.parts.first.body.decoded + assert_equal "text/html", created.parts.first.parts.second.content_type.string + assert_equal "<b>test</b> HTML<br/>", created.parts.first.parts.second.body.decoded end def test_attachment_with_custom_header @@ -391,20 +394,30 @@ class ActionMailerTest < Test::Unit::TestCase created = nil assert_nothing_raised { created = TestMailer.create_signed_up(@recipient) } assert_not_nil created + + expected.message_id = '<123@456>' + created.message_id = '<123@456>' + assert_equal expected.encoded, created.encoded assert_nothing_raised { TestMailer.deliver_signed_up(@recipient) } - assert_not_nil ActionMailer::Base.deliveries.first - assert_equal expected.encoded, ActionMailer::Base.deliveries.first.encoded + + delivered = ActionMailer::Base.deliveries.first + assert_not_nil delivered + + expected.message_id = '<123@456>' + delivered.message_id = '<123@456>' + + assert_equal expected.encoded, delivered.encoded end def test_subject_with_i18n assert_nothing_raised { TestMailer.deliver_subject_with_i18n(@recipient) } - assert_equal "Subject with i18n", ActionMailer::Base.deliveries.first.subject + assert_equal "Subject with i18n", ActionMailer::Base.deliveries.first.subject.decoded I18n.backend.store_translations('en', :actionmailer => {:test_mailer => {:subject_with_i18n => {:subject => "New Subject!"}}}) assert_nothing_raised { TestMailer.deliver_subject_with_i18n(@recipient) } - assert_equal "New Subject!", ActionMailer::Base.deliveries.last.subject + assert_equal "New Subject!", ActionMailer::Base.deliveries.last.subject.decoded end def test_custom_template @@ -418,6 +431,8 @@ class ActionMailerTest < Test::Unit::TestCase created = nil assert_nothing_raised { created = TestMailer.create_custom_template(@recipient) } assert_not_nil created + expected.message_id = '<123@456>' + created.message_id = '<123@456>' assert_equal expected.encoded, created.encoded end @@ -440,8 +455,8 @@ class ActionMailerTest < Test::Unit::TestCase assert_nothing_raised { created = TestMailer.create_custom_templating_extension(@recipient) } assert_not_nil created assert_equal 2, created.parts.length - assert_equal 'text/plain', created.parts[0].content_type - assert_equal 'text/html', created.parts[1].content_type + assert_equal 'text/plain', created.parts[0].content_type.string + assert_equal 'text/html', created.parts[1].content_type.string end def test_cancelled_account @@ -455,11 +470,17 @@ class ActionMailerTest < Test::Unit::TestCase created = nil assert_nothing_raised { created = TestMailer.create_cancelled_account(@recipient) } assert_not_nil created + expected.message_id = '<123@456>' + created.message_id = '<123@456>' assert_equal expected.encoded, created.encoded assert_nothing_raised { TestMailer.deliver_cancelled_account(@recipient) } assert_not_nil ActionMailer::Base.deliveries.first - assert_equal expected.encoded, ActionMailer::Base.deliveries.first.encoded + delivered = ActionMailer::Base.deliveries.first + expected.message_id = '<123@456>' + delivered.message_id = '<123@456>' + + assert_equal expected.encoded, delivered.encoded end def test_cc_bcc @@ -477,6 +498,8 @@ class ActionMailerTest < Test::Unit::TestCase created = TestMailer.create_cc_bcc @recipient end assert_not_nil created + expected.message_id = '<123@456>' + created.message_id = '<123@456>' assert_equal expected.encoded, created.encoded assert_nothing_raised do @@ -484,7 +507,11 @@ class ActionMailerTest < Test::Unit::TestCase end assert_not_nil ActionMailer::Base.deliveries.first - assert_equal expected.encoded, ActionMailer::Base.deliveries.first.encoded + delivered = ActionMailer::Base.deliveries.first + expected.message_id = '<123@456>' + delivered.message_id = '<123@456>' + + assert_equal expected.encoded, delivered.encoded end def test_reply_to @@ -502,14 +529,23 @@ class ActionMailerTest < Test::Unit::TestCase created = TestMailer.create_different_reply_to @recipient end assert_not_nil created + + expected.message_id = '<123@456>' + created.message_id = '<123@456>' + assert_equal expected.encoded, created.encoded assert_nothing_raised do TestMailer.deliver_different_reply_to @recipient end - assert_not_nil ActionMailer::Base.deliveries.first - assert_equal expected.encoded, ActionMailer::Base.deliveries.first.encoded + delivered = ActionMailer::Base.deliveries.first + assert_not_nil delivered + + expected.message_id = '<123@456>' + delivered.message_id = '<123@456>' + + assert_equal expected.encoded, delivered.encoded end def test_iso_charset @@ -527,14 +563,23 @@ class ActionMailerTest < Test::Unit::TestCase created = TestMailer.create_iso_charset @recipient end assert_not_nil created + + expected.message_id = '<123@456>' + created.message_id = '<123@456>' + assert_equal expected.encoded, created.encoded assert_nothing_raised do TestMailer.deliver_iso_charset @recipient end - assert_not_nil ActionMailer::Base.deliveries.first - assert_equal expected.encoded, ActionMailer::Base.deliveries.first.encoded + delivered = ActionMailer::Base.deliveries.first + assert_not_nil delivered + + expected.message_id = '<123@456>' + delivered.message_id = '<123@456>' + + assert_equal expected.encoded, delivered.encoded end def test_unencoded_subject @@ -552,14 +597,23 @@ class ActionMailerTest < Test::Unit::TestCase created = TestMailer.create_unencoded_subject @recipient end assert_not_nil created + + expected.message_id = '<123@456>' + created.message_id = '<123@456>' + assert_equal expected.encoded, created.encoded assert_nothing_raised do TestMailer.deliver_unencoded_subject @recipient end - assert_not_nil ActionMailer::Base.deliveries.first - assert_equal expected.encoded, ActionMailer::Base.deliveries.first.encoded + delivered = ActionMailer::Base.deliveries.first + assert_not_nil delivered + + expected.message_id = '<123@456>' + delivered.message_id = '<123@456>' + + assert_equal expected.encoded, delivered.encoded end def test_instances_are_nil @@ -625,7 +679,12 @@ class ActionMailerTest < Test::Unit::TestCase TestMailer.logger = FakeLogger.new TestMailer.deliver_signed_up(@recipient) assert(TestMailer.logger.info_contents =~ /Sent mail to #{@recipient}/) - assert_equal(TestMailer.logger.debug_contents, "\n#{mail.encoded}") + expected = TestMailer.logger.debug_contents + actual = "\n#{mail.encoded}" + expected.gsub!(/Message-ID:.*\r\n/, "Message-ID: <123@456>\r\n") + actual.gsub!(/Message-ID:.*\r\n/, "Message-ID: <123@456>\r\n") + + assert_equal(expected, actual) end def test_unquote_quoted_printable_subject @@ -636,9 +695,9 @@ Content-Type: text/plain; charset=iso-8859-1 The body EOF - mail = TMail::Mail.parse(msg) - assert_equal "testing testing \326\244", mail.subject - assert_equal "=?utf-8?Q?testing_testing_=D6=A4?=", mail.quoted_subject + mail = Mail.new(msg) + assert_equal "testing testing \326\244", mail.subject.decoded + assert_equal "Subject: =?utf-8?Q?testing_testing_=D6=A4?=\r\n", mail.subject.encoded end def test_unquote_7bit_subject @@ -649,9 +708,9 @@ Content-Type: text/plain; charset=iso-8859-1 The body EOF - mail = TMail::Mail.parse(msg) - assert_equal "this == working?", mail.subject - assert_equal "this == working?", mail.quoted_subject + mail = Mail.new(msg) + assert_equal "this == working?", mail.subject.decoded + assert_equal "Subject: this == working?\r\n", mail.subject.encoded end def test_unquote_7bit_body @@ -663,9 +722,9 @@ Content-Transfer-Encoding: 7bit The=3Dbody EOF - mail = TMail::Mail.parse(msg) - assert_equal "The=3Dbody", mail.body.strip - assert_equal "The=3Dbody", mail.quoted_body.strip + mail = Mail.new(msg) + assert_equal "The=3Dbody", mail.body.decoded.strip + assert_equal "The=3Dbody", mail.body.encoded.strip end def test_unquote_quoted_printable_body @@ -677,9 +736,9 @@ Content-Transfer-Encoding: quoted-printable The=3Dbody EOF - mail = TMail::Mail.parse(msg) - assert_equal "The=body", mail.body.strip - assert_equal "The=3Dbody", mail.quoted_body.strip + mail = Mail.new(msg) + assert_equal "The=body", mail.body.decoded.strip + assert_equal "The=3Dbody", mail.body.encoded.strip end def test_unquote_base64_body @@ -691,9 +750,9 @@ Content-Transfer-Encoding: base64 VGhlIGJvZHk= EOF - mail = TMail::Mail.parse(msg) - assert_equal "The body", mail.body.strip - assert_equal "VGhlIGJvZHk=", mail.quoted_body.strip + mail = Mail.new(msg) + assert_equal "The body", mail.body.decoded.strip + assert_equal "VGhlIGJvZHk=", mail.body.encoded.strip end def test_extended_headers @@ -714,14 +773,22 @@ EOF end assert_not_nil created + expected.message_id = '<123@456>' + created.message_id = '<123@456>' + assert_equal expected.encoded, created.encoded assert_nothing_raised do TestMailer.deliver_extended_headers @recipient end - assert_not_nil ActionMailer::Base.deliveries.first - assert_equal expected.encoded, ActionMailer::Base.deliveries.first.encoded + delivered = ActionMailer::Base.deliveries.first + assert_not_nil delivered + + expected.message_id = '<123@456>' + delivered.message_id = '<123@456>' + + assert_equal expected.encoded, delivered.encoded end def test_utf8_body_is_not_quoted @@ -752,40 +819,40 @@ EOF created = TestMailer.create_utf8_body @recipient assert_match(/\nFrom: =\?utf-8\?Q\?Foo_.*?\?= <extended@example.net>\r/, created.encoded) - assert_match(/\nTo: =\?utf-8\?Q\?Foo_.*?\?= <extended@example.net>, Example Recipient <me/, created.encoded) + assert_match(/\nTo: =\?utf-8\?Q\?Foo_.*?\?= <extended@example.net>, \r\n\tExample Recipient <me/, created.encoded) end def test_receive_decodes_base64_encoded_mail fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email") TestMailer.receive(fixture) - assert_match(/Jamis/, TestMailer.received_body) + assert_match(/Jamis/, TestMailer.received_body.decoded) end def test_receive_attachments fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email2") - mail = TMail::Mail.parse(fixture) + mail = Mail.new(fixture) attachment = mail.attachments.last assert_equal "smime.p7s", attachment.original_filename - assert_equal "application/pkcs7-signature", attachment.content_type + assert_equal "application/pkcs7-signature", mail.parts.last.content_type.string end def test_decode_attachment_without_charset fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email3") - mail = TMail::Mail.parse(fixture) + mail = Mail.new(fixture) attachment = mail.attachments.last assert_equal 1026, attachment.read.length end def test_attachment_using_content_location fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email12") - mail = TMail::Mail.parse(fixture) + mail = Mail.new(fixture) assert_equal 1, mail.attachments.length assert_equal "Photo25.jpg", mail.attachments.first.original_filename end def test_attachment_with_text_type fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email13") - mail = TMail::Mail.parse(fixture) + mail = Mail.new(fixture) assert mail.has_attachments? assert_equal 1, mail.attachments.length assert_equal "hello.rb", mail.attachments.first.original_filename @@ -793,25 +860,25 @@ EOF def test_decode_part_without_content_type fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email4") - mail = TMail::Mail.parse(fixture) + mail = Mail.new(fixture) assert_nothing_raised { mail.body } end def test_decode_message_without_content_type fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email5") - mail = TMail::Mail.parse(fixture) + mail = Mail.new(fixture) assert_nothing_raised { mail.body } end def test_decode_message_with_incorrect_charset fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email6") - mail = TMail::Mail.parse(fixture) + mail = Mail.new(fixture) assert_nothing_raised { mail.body } end def test_multipart_with_mime_version mail = TestMailer.create_multipart_with_mime_version(@recipient) - assert_equal "1.1", mail.mime_version + assert_equal "1.1", mail.mime_version.version end def test_multipart_with_utf8_subject @@ -827,30 +894,31 @@ EOF def test_explicitly_multipart_messages mail = TestMailer.create_explicitly_multipart_example(@recipient) assert_equal 3, mail.parts.length - assert_nil mail.content_type - assert_equal "text/plain", mail.parts[0].content_type + assert_equal 'multipart/mixed', mail.content_type.string - assert_equal "text/html", mail.parts[1].content_type - assert_equal "iso-8859-1", mail.parts[1].sub_header("content-type", "charset") - assert_equal "inline", mail.parts[1].content_disposition + assert_equal "text/plain", mail.parts[0].content_type.string - assert_equal "image/jpeg", mail.parts[2].content_type - assert_equal "attachment", mail.parts[2].content_disposition - assert_equal "foo.jpg", mail.parts[2].sub_header("content-disposition", "filename") - assert_equal "foo.jpg", mail.parts[2].sub_header("content-type", "name") - assert_nil mail.parts[2].sub_header("content-type", "charset") + assert_equal "text/html", mail.parts[1].content_type.string + assert_equal "iso-8859-1", mail.parts[1].charset + + assert_equal "image/jpeg", mail.parts[2].content_type.string + assert_equal "attachment", mail.parts[2].content_disposition.disposition_type + + assert_equal "foo.jpg", mail.parts[2].content_disposition.filename + assert_equal "foo.jpg", mail.parts[2].content_type.filename + assert_nil mail.parts[2].charset end def test_explicitly_multipart_with_content_type mail = TestMailer.create_explicitly_multipart_example(@recipient, "multipart/alternative") assert_equal 3, mail.parts.length - assert_equal "multipart/alternative", mail.content_type + assert_equal "multipart/alternative", mail.content_type.string end def test_explicitly_multipart_with_invalid_content_type mail = TestMailer.create_explicitly_multipart_example(@recipient, "text/xml") assert_equal 3, mail.parts.length - assert_nil mail.content_type + assert_equal 'multipart/mixed', mail.content_type.string end def test_implicitly_multipart_messages @@ -858,14 +926,14 @@ EOF mail = TestMailer.create_implicitly_multipart_example(@recipient) assert_equal 3, mail.parts.length - assert_equal "1.0", mail.mime_version - assert_equal "multipart/alternative", mail.content_type - assert_equal "application/x-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") + assert_equal "1.0", mail.mime_version.decoded + assert_equal "multipart/alternative", mail.content_type.string + assert_equal "application/x-yaml", mail.parts[0].content_type.string + assert_equal "utf-8", mail.parts[0].charset + assert_equal "text/plain", mail.parts[1].content_type.string + assert_equal "utf-8", mail.parts[1].charset + assert_equal "text/html", mail.parts[2].content_type.string + assert_equal "utf-8", mail.parts[2].charset end def test_implicitly_multipart_messages_with_custom_order @@ -873,41 +941,43 @@ EOF mail = TestMailer.create_implicitly_multipart_example(@recipient, nil, ["application/x-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 "application/x-yaml", mail.parts[2].content_type + assert_equal "text/html", mail.parts[0].content_type.string + assert_equal "text/plain", mail.parts[1].content_type.string + assert_equal "application/x-yaml", mail.parts[2].content_type.string end def test_implicitly_multipart_messages_with_charset mail = TestMailer.create_implicitly_multipart_example(@recipient, 'iso-8859-1') - assert_equal "multipart/alternative", mail.header['content-type'].body + assert_equal "multipart/alternative", mail.header['content-type'].content_type - assert_equal 'iso-8859-1', mail.parts[0].sub_header("content-type", "charset") - assert_equal 'iso-8859-1', mail.parts[1].sub_header("content-type", "charset") - assert_equal 'iso-8859-1', mail.parts[2].sub_header("content-type", "charset") + assert_equal 'iso-8859-1', mail.parts[0].content_type.parameters[:charset] + assert_equal 'iso-8859-1', mail.parts[1].content_type.parameters[:charset] + assert_equal 'iso-8859-1', mail.parts[2].content_type.parameters[:charset] end def test_html_mail mail = TestMailer.create_html_mail(@recipient) - assert_equal "text/html", mail.content_type + assert_equal "text/html", mail.content_type.string end def test_html_mail_with_underscores mail = TestMailer.create_html_mail_with_underscores(@recipient) - assert_equal %{<a href="http://google.com" target="_blank">_Google</a>}, mail.body + assert_equal %{<a href="http://google.com" target="_blank">_Google</a>}, mail.body.decoded end def test_various_newlines mail = TestMailer.create_various_newlines(@recipient) assert_equal("line #1\nline #2\nline #3\nline #4\n\n" + - "line #5\n\nline#6\n\nline #7", mail.body) + "line #5\n\nline#6\n\nline #7", mail.body.decoded) end def test_various_newlines_multipart mail = TestMailer.create_various_newlines_multipart(@recipient) - assert_equal "line #1\nline #2\nline #3\nline #4\n\n", mail.parts[0].body - assert_equal "<p>line #1</p>\n<p>line #2</p>\n<p>line #3</p>\n<p>line #4</p>\n\n", mail.parts[1].body + assert_equal "line #1\nline #2\nline #3\nline #4\n\n", mail.parts[0].body.decoded + assert_equal "<p>line #1</p>\n<p>line #2</p>\n<p>line #3</p>\n<p>line #4</p>\n\n", mail.parts[1].body.decoded + assert_equal "line #1\r\nline #2\r\nline #3\r\nline #4\r\n\r\n", mail.parts[0].body.encoded + assert_equal "<p>line #1</p>\r\n<p>line #2</p>\r\n<p>line #3</p>\r\n<p>line #4</p>\r\n\r\n", mail.parts[1].body.encoded end def test_headers_removed_on_smtp_delivery @@ -935,13 +1005,18 @@ EOF def test_recursive_multipart_processing fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email7") - mail = TMail::Mail.parse(fixture) - assert_equal "This is the first part.\n\nAttachment: test.rb\nAttachment: test.pdf\n\n\nAttachment: smime.p7s\n", mail.body + mail = Mail.new(fixture) + assert_equal(2, mail.parts.length) + assert_equal(4, mail.parts.first.parts.length) + assert_equal("This is the first part.", mail.parts.first.parts.first.body.decoded) + assert_equal("test.rb", mail.parts.first.parts.second.filename) + assert_equal("flowed", mail.parts.first.parts.fourth.content_type.parameters[:format]) + assert_equal('smime.p7s', mail.parts.second.filename) end def test_decode_encoded_attachment_filename fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email8") - mail = TMail::Mail.parse(fixture) + mail = Mail.new(fixture) attachment = mail.attachments.last expected = "01 Quien Te Dij\212at. Pitbull.mp3" @@ -950,20 +1025,15 @@ EOF assert_equal expected, attachment.original_filename end - def test_wrong_mail_header - fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email9") - assert_raise(TMail::SyntaxError) { TMail::Mail.parse(fixture) } - end - def test_decode_message_with_unknown_charset fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email10") - mail = TMail::Mail.parse(fixture) + mail = Mail.new(fixture) assert_nothing_raised { mail.body } end def test_empty_header_values_omitted result = TestMailer.create_unnamed_attachment(@recipient).encoded - assert_match %r{Content-Type: application/octet-stream[^;]}, result + assert_match %r{Content-Type: application/octet-stream;}, result assert_match %r{Content-Disposition: attachment[^;]}, result end @@ -986,31 +1056,31 @@ EOF def test_multipart_with_template_path_with_dots mail = FunkyPathMailer.create_multipart_with_template_path_with_dots(@recipient) assert_equal 2, mail.parts.length - assert "text/plain", mail.parts[1].content_type + assert "text/plain", mail.parts[1].content_type.string assert "utf-8", mail.parts[1].charset end def test_custom_content_type_attributes mail = TestMailer.create_custom_content_type_attributes - assert_match %r{format=flowed}, mail['content-type'].to_s - assert_match %r{charset=utf-8}, mail['content-type'].to_s + assert_match %r{format="flowed"}, mail.content_type.encoded + assert_match %r{charset="utf-8"}, mail.content_type.encoded end def test_return_path_with_create mail = TestMailer.create_return_path - assert_equal "<another@somewhere.test>", mail['return-path'].to_s + assert_equal "another@somewhere.test", mail['return-path'].decoded.to_s end def test_return_path_with_deliver ActionMailer::Base.delivery_method = :smtp TestMailer.deliver_return_path - assert_match %r{^Return-Path: <another@somewhere.test>}, MockSMTP.deliveries[0][0] + assert_match %r{^Return-Path: another@somewhere.test}, MockSMTP.deliveries[0][0] assert_equal "another@somewhere.test", MockSMTP.deliveries[0][1].to_s end def test_body_is_stored_as_an_ivar mail = TestMailer.create_body_ivar(@recipient) - assert_equal "body: foo\nbar: baz", mail.body + assert_equal "body: foo\nbar: baz", mail.body.decoded end def test_starttls_is_enabled_if_supported |