diff options
Diffstat (limited to 'actionmailer/test')
-rw-r--r-- | actionmailer/test/asset_host_test.rb | 6 | ||||
-rw-r--r-- | actionmailer/test/mail_helper_test.rb | 2 | ||||
-rw-r--r-- | actionmailer/test/mail_layout_test.rb | 62 | ||||
-rw-r--r-- | actionmailer/test/mail_render_test.rb | 28 | ||||
-rw-r--r-- | actionmailer/test/mail_service_test.rb | 69 | ||||
-rw-r--r-- | actionmailer/test/quoting_test.rb | 12 | ||||
-rw-r--r-- | actionmailer/test/test_helper_test.rb | 4 | ||||
-rw-r--r-- | actionmailer/test/tmail_test.rb | 7 | ||||
-rw-r--r-- | actionmailer/test/url_test.rb | 2 |
9 files changed, 112 insertions, 80 deletions
diff --git a/actionmailer/test/asset_host_test.rb b/actionmailer/test/asset_host_test.rb index 1c92dd266d..0b74fe8c24 100644 --- a/actionmailer/test/asset_host_test.rb +++ b/actionmailer/test/asset_host_test.rb @@ -24,7 +24,7 @@ class AssetHostTest < Test::Unit::TestCase def test_asset_host_as_string ActionController::Base.asset_host = "http://www.example.com" mail = AssetHostMailer.deliver_email_with_asset(@recipient) - assert_equal "<img alt=\"Somelogo\" src=\"http://www.example.com/images/somelogo.png\" />", mail.body.strip + assert_equal "<img alt=\"Somelogo\" src=\"http://www.example.com/images/somelogo.png\" />", mail.body.decoded.strip end def test_asset_host_as_one_arguement_proc @@ -36,7 +36,7 @@ class AssetHostTest < Test::Unit::TestCase end } mail = AssetHostMailer.deliver_email_with_asset(@recipient) - assert_equal "<img alt=\"Somelogo\" src=\"http://images.example.com/images/somelogo.png\" />", mail.body.strip + assert_equal "<img alt=\"Somelogo\" src=\"http://images.example.com/images/somelogo.png\" />", mail.body.decoded.strip end def test_asset_host_as_two_arguement_proc @@ -49,6 +49,6 @@ class AssetHostTest < Test::Unit::TestCase } mail = nil assert_nothing_raised { mail = AssetHostMailer.deliver_email_with_asset(@recipient) } - assert_equal "<img alt=\"Somelogo\" src=\"http://www.example.com/images/somelogo.png\" />", mail.body.strip + assert_equal "<img alt=\"Somelogo\" src=\"http://www.example.com/images/somelogo.png\" />", mail.body.decoded.strip end end
\ No newline at end of file diff --git a/actionmailer/test/mail_helper_test.rb b/actionmailer/test/mail_helper_test.rb index f8b002e0a7..7b0716048f 100644 --- a/actionmailer/test/mail_helper_test.rb +++ b/actionmailer/test/mail_helper_test.rb @@ -55,7 +55,7 @@ end class MailerHelperTest < Test::Unit::TestCase def new_mail( charset="utf-8" ) - mail = TMail::Mail.new + mail = Mail.new mail.set_content_type "text", "plain", { "charset" => charset } if charset mail end diff --git a/actionmailer/test/mail_layout_test.rb b/actionmailer/test/mail_layout_test.rb index f37c26ff69..8df5a2000a 100644 --- a/actionmailer/test/mail_layout_test.rb +++ b/actionmailer/test/mail_layout_test.rb @@ -65,63 +65,85 @@ class LayoutMailerTest < Test::Unit::TestCase def test_should_pickup_default_layout mail = AutoLayoutMailer.create_hello(@recipient) - assert_equal "Hello from layout Inside", mail.body.strip + assert_equal "Hello from layout Inside", mail.body.decoded.strip end def test_should_pickup_multipart_layout mail = AutoLayoutMailer.create_multipart(@recipient) - assert_equal "multipart/alternative", mail.content_type + # CHANGED: content_type returns an object + # assert_equal "multipart/alternative", mail.content_type + assert_equal "multipart/alternative", mail.content_type.content_type assert_equal 2, mail.parts.size - assert_equal 'text/plain', mail.parts.first.content_type - assert_equal "text/plain layout - text/plain multipart", mail.parts.first.body + # CHANGED: content_type returns an object + # assert_equal 'text/plain', mail.parts.first.content_type + assert_equal 'text/plain', mail.parts.first.content_type.content_type + + # CHANGED: body returns an object + # assert_equal "text/plain layout - text/plain multipart", mail.parts.first.body + assert_equal "text/plain layout - text/plain multipart", mail.parts.first.body.decoded - assert_equal 'text/html', mail.parts.last.content_type - assert_equal "Hello from layout text/html multipart", mail.parts.last.body + # CHANGED: content_type returns an object + # assert_equal 'text/html', mail.parts.last.content_type + assert_equal 'text/html', mail.parts.last.content_type.content_type + + # CHANGED: body returns an object + # assert_equal "Hello from layout text/html multipart", mail.parts.last.body + assert_equal "Hello from layout text/html multipart", mail.parts.last.body.decoded end def test_should_pickup_multipartmixed_layout mail = AutoLayoutMailer.create_multipart(@recipient, "multipart/mixed") - assert_equal "multipart/mixed", mail.content_type + # CHANGED: content_type returns an object + # assert_equal "multipart/mixed", mail.content_type + assert_equal "multipart/mixed", mail.content_type.content_type assert_equal 2, mail.parts.size - assert_equal 'text/plain', mail.parts.first.content_type - assert_equal "text/plain layout - text/plain multipart", mail.parts.first.body + # CHANGED: content_type returns an object + # assert_equal 'text/plain', mail.parts.first.content_type + assert_equal 'text/plain', mail.parts.first.content_type.content_type + # CHANGED: body returns an object + # assert_equal "text/plain layout - text/plain multipart", mail.parts.first.body + assert_equal "text/plain layout - text/plain multipart", mail.parts.first.body.decoded - assert_equal 'text/html', mail.parts.last.content_type - assert_equal "Hello from layout text/html multipart", mail.parts.last.body + # CHANGED: content_type returns an object + # assert_equal 'text/html', mail.parts.last.content_type + assert_equal 'text/html', mail.parts.last.content_type.content_type + # CHANGED: body returns an object + # assert_equal "Hello from layout text/html multipart", mail.parts.last.body + assert_equal "Hello from layout text/html multipart", mail.parts.last.body.decoded end def test_should_fix_multipart_layout mail = AutoLayoutMailer.create_multipart(@recipient, "text/plain") - assert_equal "multipart/alternative", mail.content_type + assert_equal "multipart/alternative", mail.content_type.content_type assert_equal 2, mail.parts.size - assert_equal 'text/plain', mail.parts.first.content_type - assert_equal "text/plain layout - text/plain multipart", mail.parts.first.body + assert_equal 'text/plain', mail.parts.first.content_type.content_type + assert_equal "text/plain layout - text/plain multipart", mail.parts.first.body.decoded - assert_equal 'text/html', mail.parts.last.content_type - assert_equal "Hello from layout text/html multipart", mail.parts.last.body + assert_equal 'text/html', mail.parts.last.content_type.content_type + assert_equal "Hello from layout text/html multipart", mail.parts.last.body.decoded end def test_should_pickup_layout_given_to_render mail = AutoLayoutMailer.create_spam(@recipient) - assert_equal "Spammer layout Hello, Earth", mail.body.strip + assert_equal "Spammer layout Hello, Earth", mail.body.decoded.strip end def test_should_respect_layout_false mail = AutoLayoutMailer.create_nolayout(@recipient) - assert_equal "Hello, Earth", mail.body.strip + assert_equal "Hello, Earth", mail.body.decoded.strip end def test_explicit_class_layout mail = ExplicitLayoutMailer.create_signup(@recipient) - assert_equal "Spammer layout We do not spam", mail.body.strip + assert_equal "Spammer layout We do not spam", mail.body.decoded.strip end def test_explicit_layout_exceptions mail = ExplicitLayoutMailer.create_logout(@recipient) - assert_equal "You logged out", mail.body.strip + assert_equal "You logged out", mail.body.decoded.strip end end diff --git a/actionmailer/test/mail_render_test.rb b/actionmailer/test/mail_render_test.rb index 514f7ed798..3c97ad2a03 100644 --- a/actionmailer/test/mail_render_test.rb +++ b/actionmailer/test/mail_render_test.rb @@ -86,27 +86,37 @@ class RenderHelperTest < Test::Unit::TestCase def test_implicit_body mail = RenderMailer.create_implicit_body(@recipient) - assert_equal "Hello there, \n\nMr. test@localhost", mail.body.strip + # CHANGED: body returns an object now + # assert_equal "Hello there, \n\nMr. test@localhost", mail.body.strip + assert_equal "Hello there, \n\nMr. test@localhost", mail.body.decoded.strip end def test_inline_template mail = RenderMailer.create_inline_template(@recipient) - assert_equal "Hello, Earth", mail.body.strip + # CHANGED: body returns an object now + # assert_equal "Hello, Earth", mail.body.strip + assert_equal "Hello, Earth", mail.body.decoded.strip end def test_file_template mail = RenderMailer.create_file_template(@recipient) - assert_equal "Hello there, \n\nMr. test@localhost", mail.body.strip + # CHANGED: body returns an object now + # assert_equal "Hello there, \n\nMr. test@localhost", mail.body.strip + assert_equal "Hello there, \n\nMr. test@localhost", mail.body.decoded.strip end def test_rxml_template mail = RenderMailer.deliver_rxml_template(@recipient) - assert_equal "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<test/>", mail.body.strip + # CHANGED: body returns an object now + # assert_equal "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<test/>", mail.body.strip + assert_equal "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<test/>", mail.body.decoded.strip end def test_included_subtemplate mail = RenderMailer.deliver_included_subtemplate(@recipient) - assert_equal "Hey Ho, let's go!", mail.body.strip + # CHANGED: body returns an object now + # assert_equal "Hey Ho, let's go!", mail.body.strip + assert_equal "Hey Ho, let's go!", mail.body.decoded.strip end end @@ -125,12 +135,12 @@ class FirstSecondHelperTest < Test::Unit::TestCase def test_ordering mail = FirstMailer.create_share(@recipient) - assert_equal "first mail", mail.body.strip + assert_equal "first mail", mail.body.decoded.strip mail = SecondMailer.create_share(@recipient) - assert_equal "second mail", mail.body.strip + assert_equal "second mail", mail.body.decoded.strip mail = FirstMailer.create_share(@recipient) - assert_equal "first mail", mail.body.strip + assert_equal "first mail", mail.body.decoded.strip mail = SecondMailer.create_share(@recipient) - assert_equal "second mail", mail.body.strip + assert_equal "second mail", mail.body.decoded.strip end end diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index f9365ea90c..077c5c4480 100644 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -319,7 +319,7 @@ 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 } @@ -400,11 +400,11 @@ class ActionMailerTest < Test::Unit::TestCase 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 => {:subjects => {:test_mailer => {:subject_with_i18n => "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 @@ -636,8 +636,8 @@ Content-Type: text/plain; charset=iso-8859-1 The body EOF - mail = TMail::Mail.parse(msg) - assert_equal "testing testing \326\244", mail.subject + mail = Mail.parse(msg) + assert_equal "testing testing \326\244", mail.subject.decoded assert_equal "=?utf-8?Q?testing_testing_=D6=A4?=", mail.quoted_subject end @@ -649,8 +649,8 @@ Content-Type: text/plain; charset=iso-8859-1 The body EOF - mail = TMail::Mail.parse(msg) - assert_equal "this == working?", mail.subject + mail = Mail.parse(msg) + assert_equal "this == working?", mail.subject.decoded assert_equal "this == working?", mail.quoted_subject end @@ -663,8 +663,8 @@ Content-Transfer-Encoding: 7bit The=3Dbody EOF - mail = TMail::Mail.parse(msg) - assert_equal "The=3Dbody", mail.body.strip + mail = Mail.parse(msg) + assert_equal "The=3Dbody", mail.body.decoded.strip assert_equal "The=3Dbody", mail.quoted_body.strip end @@ -677,8 +677,8 @@ Content-Transfer-Encoding: quoted-printable The=3Dbody EOF - mail = TMail::Mail.parse(msg) - assert_equal "The=body", mail.body.strip + mail = Mail.parse(msg) + assert_equal "The=body", mail.body.decoded.strip assert_equal "The=3Dbody", mail.quoted_body.strip end @@ -691,8 +691,8 @@ Content-Transfer-Encoding: base64 VGhlIGJvZHk= EOF - mail = TMail::Mail.parse(msg) - assert_equal "The body", mail.body.strip + mail = Mail.parse(msg) + assert_equal "The body", mail.body.decoded.strip assert_equal "VGhlIGJvZHk=", mail.quoted_body.strip end @@ -763,7 +763,7 @@ EOF def test_receive_attachments fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email2") - mail = TMail::Mail.parse(fixture) + mail = Mail.parse(fixture) attachment = mail.attachments.last assert_equal "smime.p7s", attachment.original_filename assert_equal "application/pkcs7-signature", attachment.content_type @@ -771,21 +771,21 @@ EOF def test_decode_attachment_without_charset fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email3") - mail = TMail::Mail.parse(fixture) + mail = Mail.parse(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.parse(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.parse(fixture) assert mail.has_attachments? assert_equal 1, mail.attachments.length assert_equal "hello.rb", mail.attachments.first.original_filename @@ -793,19 +793,19 @@ EOF def test_decode_part_without_content_type fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email4") - mail = TMail::Mail.parse(fixture) + mail = Mail.parse(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.parse(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.parse(fixture) assert_nothing_raised { mail.body } end @@ -890,24 +890,24 @@ EOF def test_html_mail mail = TestMailer.create_html_mail(@recipient) - assert_equal "text/html", mail.content_type + assert_equal "text/html", mail.content_type.decoded 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 end def test_headers_removed_on_smtp_delivery @@ -935,13 +935,13 @@ 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.parse(fixture) + assert_equal "This is the first part.\n\nAttachment: test.rb\nAttachment: test.pdf\n\n\nAttachment: smime.p7s\n", mail.body.decoded end def test_decode_encoded_attachment_filename fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email8") - mail = TMail::Mail.parse(fixture) + mail = Mail.parse(fixture) attachment = mail.attachments.last expected = "01 Quien Te Dij\212at. Pitbull.mp3" @@ -950,14 +950,9 @@ 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.parse(fixture) assert_nothing_raised { mail.body } end @@ -986,8 +981,8 @@ 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 "utf-8", mail.parts[1].charset + assert "text/plain", mail.parts[1].content_type.content_type + assert "utf-8", mail.parts[1].content_type['charset'] end def test_custom_content_type_attributes @@ -998,7 +993,7 @@ EOF 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 diff --git a/actionmailer/test/quoting_test.rb b/actionmailer/test/quoting_test.rb index 2fee1379db..edac786906 100644 --- a/actionmailer/test/quoting_test.rb +++ b/actionmailer/test/quoting_test.rb @@ -65,13 +65,17 @@ class QuotingTest < Test::Unit::TestCase # test an email that has been created using \r\n newlines, instead of # \n newlines. def test_email_quoted_with_0d0a - mail = TMail::Mail.parse(IO.read("#{File.dirname(__FILE__)}/fixtures/raw_email_quoted_with_0d0a")) - assert_match %r{Elapsed time}, mail.body + mail = Mail.parse(IO.read("#{File.dirname(__FILE__)}/fixtures/raw_email_quoted_with_0d0a")) + # CHANGED: subject returns an object now + # assert_match %r{Elapsed time}, mail.body + assert_match %r{Elapsed time}, mail.body.decoded end def test_email_with_partially_quoted_subject - mail = TMail::Mail.parse(IO.read("#{File.dirname(__FILE__)}/fixtures/raw_email_with_partially_quoted_subject")) - assert_equal "Re: Test: \"\346\274\242\345\255\227\" mid \"\346\274\242\345\255\227\" tail", mail.subject + mail = Mail.parse(IO.read("#{File.dirname(__FILE__)}/fixtures/raw_email_with_partially_quoted_subject")) + # CHANGED: subject returns an object now + # assert_equal "Re: Test: \"\346\274\242\345\255\227\" mid \"\346\274\242\345\255\227\" tail", mail.subject + assert_equal "Re: Test: \"\346\274\242\345\255\227\" mid \"\346\274\242\345\255\227\" tail", mail.subject.decoded end private diff --git a/actionmailer/test/test_helper_test.rb b/actionmailer/test/test_helper_test.rb index 34c5243936..92527dcef9 100644 --- a/actionmailer/test/test_helper_test.rb +++ b/actionmailer/test/test_helper_test.rb @@ -18,7 +18,7 @@ class TestHelperMailerTest < ActionMailer::TestCase end def test_setup_creates_the_expected_mailer - assert @expected.is_a?(TMail::Mail) + assert @expected.is_a?(Mail) assert_equal "1.0", @expected.mime_version assert_equal "text/plain", @expected.content_type end @@ -125,7 +125,7 @@ class AnotherTestHelperMailerTest < ActionMailer::TestCase end def test_setup_shouldnt_conflict_with_mailer_setup - assert @expected.is_a?(TMail::Mail) + assert @expected.is_a?(Mail) assert_equal 'a value', @test_var end end diff --git a/actionmailer/test/tmail_test.rb b/actionmailer/test/tmail_test.rb index 718990e79e..2097efdd65 100644 --- a/actionmailer/test/tmail_test.rb +++ b/actionmailer/test/tmail_test.rb @@ -2,18 +2,19 @@ require 'abstract_unit' class TMailMailTest < Test::Unit::TestCase def test_body - m = TMail::Mail.new + m = Mail.new expected = 'something_with_underscores' m.encoding = 'quoted-printable' quoted_body = [expected].pack('*M') m.body = quoted_body assert_equal "something_with_underscores=\n", m.quoted_body - assert_equal expected, m.body + # CHANGED: body returns object, not string, Changed m.body to m.body.decoded + assert_equal expected, m.body.decoded end def test_nested_attachments_are_recognized_correctly fixture = File.read("#{File.dirname(__FILE__)}/fixtures/raw_email_with_nested_attachment") - mail = TMail::Mail.parse(fixture) + mail = Mail.parse(fixture) assert_equal 2, mail.attachments.length assert_equal "image/png", mail.attachments.first.content_type assert_equal 1902, mail.attachments.first.length diff --git a/actionmailer/test/url_test.rb b/actionmailer/test/url_test.rb index 2224f6321c..f654b2a3ae 100644 --- a/actionmailer/test/url_test.rb +++ b/actionmailer/test/url_test.rb @@ -31,7 +31,7 @@ class ActionMailerUrlTest < 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 } |