From 15d7cac282e29f0a8e7b38dade07abb32d97a991 Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Thu, 12 Nov 2009 16:08:50 +1100 Subject: Starting again on actionmailer integration with mail --- actionmailer/test/asset_host_test.rb | 6 +-- actionmailer/test/mail_helper_test.rb | 2 +- actionmailer/test/mail_layout_test.rb | 62 ++++++++++++++++++++---------- actionmailer/test/mail_render_test.rb | 28 +++++++++----- actionmailer/test/mail_service_test.rb | 69 ++++++++++++++++------------------ actionmailer/test/quoting_test.rb | 12 ++++-- actionmailer/test/test_helper_test.rb | 4 +- actionmailer/test/tmail_test.rb | 7 ++-- actionmailer/test/url_test.rb | 2 +- 9 files changed, 112 insertions(+), 80 deletions(-) (limited to 'actionmailer/test') 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 "\"Somelogo\"", mail.body.strip + assert_equal "\"Somelogo\"", 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 "\"Somelogo\"", mail.body.strip + assert_equal "\"Somelogo\"", 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 "\"Somelogo\"", mail.body.strip + assert_equal "\"Somelogo\"", 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 "\n", mail.body.strip + # CHANGED: body returns an object now + # assert_equal "\n", mail.body.strip + assert_equal "\n", 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 %{_Google}, mail.body + assert_equal %{_Google}, 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 "

line #1

\n

line #2

\n

line #3

\n

line #4

\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 "

line #1

\n

line #2

\n

line #3

\n

line #4

\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 "", 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 } -- cgit v1.2.3 From 539d9b355f40b1668b4ad4e8fe628e0a3d9760b8 Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Fri, 20 Nov 2009 14:10:57 +1100 Subject: More updates... 45 errors left to get it working with Mail gem --- actionmailer/test/fixtures/attachments/test.jpg | Bin 0 -> 2029 bytes actionmailer/test/mail_helper_test.rb | 2 +- actionmailer/test/mail_service_test.rb | 100 ++++++++++++++---------- actionmailer/test/quoting_test.rb | 4 +- actionmailer/test/tmail_test.rb | 2 +- actionmailer/test/url_test.rb | 2 +- 6 files changed, 62 insertions(+), 48 deletions(-) create mode 100644 actionmailer/test/fixtures/attachments/test.jpg (limited to 'actionmailer/test') diff --git a/actionmailer/test/fixtures/attachments/test.jpg b/actionmailer/test/fixtures/attachments/test.jpg new file mode 100644 index 0000000000..b976fe5e00 Binary files /dev/null and b/actionmailer/test/fixtures/attachments/test.jpg differ diff --git a/actionmailer/test/mail_helper_test.rb b/actionmailer/test/mail_helper_test.rb index 7b0716048f..a5cf789035 100644 --- a/actionmailer/test/mail_helper_test.rb +++ b/actionmailer/test/mail_helper_test.rb @@ -56,7 +56,7 @@ end class MailerHelperTest < Test::Unit::TestCase def new_mail( charset="utf-8" ) mail = Mail.new - mail.set_content_type "text", "plain", { "charset" => charset } if charset + mail.content_type ["text", "plain", { "charset" => charset }] mail end diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index 077c5c4480..75be2a01af 100644 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -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' => '' } + 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' => '' } end def unnamed_attachment(recipient) @@ -272,11 +272,12 @@ class TestMailer < ActionMailer::Base bcc "Five: Six " render :text => "testing" end - +require 'ruby-debug' def custom_content_type_attributes recipients "no.one@nowhere.test" subject "custom content types" from "some.one@somewhere.test" + debugger content_type "text/plain; format=flowed" render :text => "testing" end @@ -322,7 +323,7 @@ class ActionMailerTest < Test::Unit::TestCase 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 @@ -375,6 +376,7 @@ class ActionMailerTest < Test::Unit::TestCase def test_attachment_with_custom_header created = nil assert_nothing_raised { created = TestMailer.create_attachment_with_custom_header(@recipient) } + created.encoded assert created.parts.any? { |p| p.header['content-id'].to_s == "" } end @@ -440,12 +442,12 @@ 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.content_type + assert_equal 'text/html', created.parts[1].content_type.content_type end def test_cancelled_account - expected = new_mail + expected = new_mail('US-ASCII') expected.to = @recipient expected.subject = "[Cancelled] Goodbye #{@recipient}" expected.body = "Goodbye, Mr. #{@recipient}" @@ -455,15 +457,21 @@ 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 - expected = new_mail + expected = new_mail('US-ASCII') expected.to = @recipient expected.subject = "testing bcc/cc" expected.body = "Nothing to see here." @@ -477,6 +485,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 +494,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 @@ -636,7 +650,7 @@ Content-Type: text/plain; charset=iso-8859-1 The body EOF - mail = Mail.parse(msg) + mail = Mail.new(msg) assert_equal "testing testing \326\244", mail.subject.decoded assert_equal "=?utf-8?Q?testing_testing_=D6=A4?=", mail.quoted_subject end @@ -649,7 +663,7 @@ Content-Type: text/plain; charset=iso-8859-1 The body EOF - mail = Mail.parse(msg) + mail = Mail.new(msg) assert_equal "this == working?", mail.subject.decoded assert_equal "this == working?", mail.quoted_subject end @@ -663,7 +677,7 @@ Content-Transfer-Encoding: 7bit The=3Dbody EOF - mail = Mail.parse(msg) + mail = Mail.new(msg) assert_equal "The=3Dbody", mail.body.decoded.strip assert_equal "The=3Dbody", mail.quoted_body.strip end @@ -677,7 +691,7 @@ Content-Transfer-Encoding: quoted-printable The=3Dbody EOF - mail = Mail.parse(msg) + mail = Mail.new(msg) assert_equal "The=body", mail.body.decoded.strip assert_equal "The=3Dbody", mail.quoted_body.strip end @@ -691,7 +705,7 @@ Content-Transfer-Encoding: base64 VGhlIGJvZHk= EOF - mail = Mail.parse(msg) + mail = Mail.new(msg) assert_equal "The body", mail.body.decoded.strip assert_equal "VGhlIGJvZHk=", mail.quoted_body.strip end @@ -763,7 +777,7 @@ EOF def test_receive_attachments fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email2") - mail = 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 @@ -771,21 +785,21 @@ EOF def test_decode_attachment_without_charset fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email3") - mail = 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 = 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 = 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,19 +807,19 @@ EOF def test_decode_part_without_content_type fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email4") - mail = 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 = 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 = Mail.parse(fixture) + mail = Mail.new(fixture) assert_nothing_raised { mail.body } end @@ -858,14 +872,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.content_type + assert_equal "application/x-yaml", mail.parts[0].content_type.content_type + assert_equal "utf-8", mail.parts[0].content_type.parameters[:charset] + assert_equal "text/plain", mail.parts[1].content_type.content_type + assert_equal "utf-8", mail.parts[1].content_type.parameters[:charset] + assert_equal "text/html", mail.parts[2].content_type.content_type + assert_equal "utf-8", mail.parts[2].content_type.parameters[:charset] end def test_implicitly_multipart_messages_with_custom_order @@ -873,19 +887,19 @@ 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.content_type + assert_equal "text/plain", mail.parts[1].content_type.content_type + assert_equal "application/x-yaml", mail.parts[2].content_type.content_type 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 @@ -935,13 +949,13 @@ EOF def test_recursive_multipart_processing fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email7") - mail = Mail.parse(fixture) + mail = Mail.new(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 = Mail.parse(fixture) + mail = Mail.new(fixture) attachment = mail.attachments.last expected = "01 Quien Te Dij\212at. Pitbull.mp3" @@ -952,7 +966,7 @@ EOF def test_decode_message_with_unknown_charset fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email10") - mail = Mail.parse(fixture) + mail = Mail.new(fixture) assert_nothing_raised { mail.body } end @@ -987,8 +1001,8 @@ EOF 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 @@ -1005,7 +1019,7 @@ EOF 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.encoded end def test_starttls_is_enabled_if_supported diff --git a/actionmailer/test/quoting_test.rb b/actionmailer/test/quoting_test.rb index edac786906..1410712123 100644 --- a/actionmailer/test/quoting_test.rb +++ b/actionmailer/test/quoting_test.rb @@ -65,14 +65,14 @@ 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 = Mail.parse(IO.read("#{File.dirname(__FILE__)}/fixtures/raw_email_quoted_with_0d0a")) + mail = Mail.new(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 = Mail.parse(IO.read("#{File.dirname(__FILE__)}/fixtures/raw_email_with_partially_quoted_subject")) + mail = Mail.new(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 diff --git a/actionmailer/test/tmail_test.rb b/actionmailer/test/tmail_test.rb index 2097efdd65..2a3f2a9e55 100644 --- a/actionmailer/test/tmail_test.rb +++ b/actionmailer/test/tmail_test.rb @@ -14,7 +14,7 @@ class TMailMailTest < Test::Unit::TestCase def test_nested_attachments_are_recognized_correctly fixture = File.read("#{File.dirname(__FILE__)}/fixtures/raw_email_with_nested_attachment") - mail = Mail.parse(fixture) + mail = Mail.new(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 f654b2a3ae..427833b36c 100644 --- a/actionmailer/test/url_test.rb +++ b/actionmailer/test/url_test.rb @@ -34,7 +34,7 @@ class ActionMailerUrlTest < Test::Unit::TestCase 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 -- cgit v1.2.3 From a5e6295d72733b0ab4d5cff1003574e98913bae8 Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Fri, 20 Nov 2009 21:19:10 +1100 Subject: Down to 30 failures total --- actionmailer/test/fixtures/attachments/foo.jpg | Bin 0 -> 2029 bytes actionmailer/test/mail_helper_test.rb | 2 +- actionmailer/test/mail_layout_test.rb | 18 ++-- actionmailer/test/mail_service_test.rb | 118 +++++++++++++++++-------- 4 files changed, 92 insertions(+), 46 deletions(-) create mode 100644 actionmailer/test/fixtures/attachments/foo.jpg (limited to 'actionmailer/test') diff --git a/actionmailer/test/fixtures/attachments/foo.jpg b/actionmailer/test/fixtures/attachments/foo.jpg new file mode 100644 index 0000000000..b976fe5e00 Binary files /dev/null and b/actionmailer/test/fixtures/attachments/foo.jpg differ diff --git a/actionmailer/test/mail_helper_test.rb b/actionmailer/test/mail_helper_test.rb index a5cf789035..b750d21f8a 100644 --- a/actionmailer/test/mail_helper_test.rb +++ b/actionmailer/test/mail_helper_test.rb @@ -56,7 +56,7 @@ end class MailerHelperTest < Test::Unit::TestCase def new_mail( charset="utf-8" ) mail = Mail.new - mail.content_type ["text", "plain", { "charset" => charset }] + mail.content_type(["text", "plain", { "charset" => charset }]) mail end diff --git a/actionmailer/test/mail_layout_test.rb b/actionmailer/test/mail_layout_test.rb index 8df5a2000a..4775545039 100644 --- a/actionmailer/test/mail_layout_test.rb +++ b/actionmailer/test/mail_layout_test.rb @@ -72,12 +72,12 @@ class LayoutMailerTest < Test::Unit::TestCase mail = AutoLayoutMailer.create_multipart(@recipient) # CHANGED: content_type returns an object # assert_equal "multipart/alternative", mail.content_type - assert_equal "multipart/alternative", mail.content_type.content_type + assert_equal "multipart/alternative", mail.content_type.string assert_equal 2, mail.parts.size # 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 + assert_equal 'text/plain', mail.parts.first.content_type.string # CHANGED: body returns an object # assert_equal "text/plain layout - text/plain multipart", mail.parts.first.body @@ -85,7 +85,7 @@ class LayoutMailerTest < Test::Unit::TestCase # 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 + assert_equal 'text/html', mail.parts.last.content_type.string # CHANGED: body returns an object # assert_equal "Hello from layout text/html multipart", mail.parts.last.body @@ -96,19 +96,19 @@ class LayoutMailerTest < Test::Unit::TestCase mail = AutoLayoutMailer.create_multipart(@recipient, "multipart/mixed") # CHANGED: content_type returns an object # assert_equal "multipart/mixed", mail.content_type - assert_equal "multipart/mixed", mail.content_type.content_type + assert_equal "multipart/mixed", mail.content_type.string assert_equal 2, mail.parts.size # 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 + assert_equal 'text/plain', mail.parts.first.content_type.string # 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 # 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 + assert_equal 'text/html', mail.parts.last.content_type.string # 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 @@ -116,13 +116,13 @@ class LayoutMailerTest < Test::Unit::TestCase def test_should_fix_multipart_layout mail = AutoLayoutMailer.create_multipart(@recipient, "text/plain") - assert_equal "multipart/alternative", mail.content_type.content_type + assert_equal "multipart/alternative", mail.content_type.string assert_equal 2, mail.parts.size - assert_equal 'text/plain', mail.parts.first.content_type.content_type + assert_equal 'text/plain', mail.parts.first.content_type.string assert_equal "text/plain layout - text/plain multipart", mail.parts.first.body.decoded - assert_equal 'text/html', mail.parts.last.content_type.content_type + assert_equal 'text/html', mail.parts.last.content_type.string assert_equal "Hello from layout text/html multipart", mail.parts.last.body.decoded end diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index 75be2a01af..fb30a4dcb3 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" @@ -272,12 +272,11 @@ class TestMailer < ActionMailer::Base bcc "Five: Six " render :text => "testing" end -require 'ruby-debug' + def custom_content_type_attributes recipients "no.one@nowhere.test" subject "custom content types" from "some.one@somewhere.test" - debugger content_type "text/plain; format=flowed" render :text => "testing" end @@ -393,11 +392,21 @@ 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 @@ -420,6 +429,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 @@ -442,12 +453,12 @@ 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.content_type - assert_equal 'text/html', created.parts[1].content_type.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 - expected = new_mail('US-ASCII') + expected = new_mail expected.to = @recipient expected.subject = "[Cancelled] Goodbye #{@recipient}" expected.body = "Goodbye, Mr. #{@recipient}" @@ -471,7 +482,7 @@ class ActionMailerTest < Test::Unit::TestCase end def test_cc_bcc - expected = new_mail('US-ASCII') + expected = new_mail expected.to = @recipient expected.subject = "testing bcc/cc" expected.body = "Nothing to see here." @@ -516,14 +527,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 @@ -541,14 +561,25 @@ 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>' + + 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 @@ -639,7 +670,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 @@ -728,14 +764,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 @@ -825,7 +869,7 @@ EOF 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 @@ -842,13 +886,13 @@ EOF 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 "text/plain", mail.parts[0].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 "text/html", mail.parts[1].content_type.string + assert_equal "iso-8859-1", mail.parts[1].charset assert_equal "inline", mail.parts[1].content_disposition - assert_equal "image/jpeg", mail.parts[2].content_type + assert_equal "image/jpeg", mail.parts[2].content_type.string 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") @@ -858,7 +902,7 @@ EOF 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 @@ -873,13 +917,13 @@ EOF mail = TestMailer.create_implicitly_multipart_example(@recipient) assert_equal 3, mail.parts.length assert_equal "1.0", mail.mime_version.decoded - assert_equal "multipart/alternative", mail.content_type.content_type - assert_equal "application/x-yaml", mail.parts[0].content_type.content_type - assert_equal "utf-8", mail.parts[0].content_type.parameters[:charset] - assert_equal "text/plain", mail.parts[1].content_type.content_type - assert_equal "utf-8", mail.parts[1].content_type.parameters[:charset] - assert_equal "text/html", mail.parts[2].content_type.content_type - assert_equal "utf-8", mail.parts[2].content_type.parameters[:charset] + 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 @@ -887,9 +931,9 @@ 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.content_type - assert_equal "text/plain", mail.parts[1].content_type.content_type - assert_equal "application/x-yaml", mail.parts[2].content_type.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 @@ -904,7 +948,7 @@ EOF def test_html_mail mail = TestMailer.create_html_mail(@recipient) - assert_equal "text/html", mail.content_type.decoded + assert_equal "text/html", mail.content_type.string end def test_html_mail_with_underscores @@ -922,6 +966,8 @@ EOF mail = TestMailer.create_various_newlines_multipart(@recipient) assert_equal "line #1\nline #2\nline #3\nline #4\n\n", mail.parts[0].body.decoded assert_equal "

line #1

\n

line #2

\n

line #3

\n

line #4

\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 "

line #1

\r\n

line #2

\r\n

line #3

\r\n

line #4

\r\n\r\n", mail.parts[1].body.encoded end def test_headers_removed_on_smtp_delivery @@ -995,14 +1041,14 @@ 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.content_type + assert "text/plain", mail.parts[1].content_type.string assert "utf-8", mail.parts[1].content_type['charset'] end def test_custom_content_type_attributes mail = TestMailer.create_custom_content_type_attributes - assert_match %r{format=flowed}, mail.content_type.encoded - assert_match %r{charset=utf-8}, mail.content_type.encoded + 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 -- cgit v1.2.3 From 6456a08334703ceb91ed69b1426a171dc956e1b9 Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Fri, 20 Nov 2009 22:01:40 +1100 Subject: Down to 13 failures, 14 errors --- actionmailer/test/mail_service_test.rb | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'actionmailer/test') diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index fb30a4dcb3..6c61bc8c00 100644 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -561,12 +561,10 @@ 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>' expected.message_id = '<123@456>' created.message_id = '<123@456>' - + assert_equal expected.encoded, created.encoded assert_nothing_raised do @@ -597,14 +595,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 @@ -1065,7 +1072,7 @@ EOF def test_body_is_stored_as_an_ivar mail = TestMailer.create_body_ivar(@recipient) - assert_equal "body: foo\nbar: baz", mail.body.encoded + assert_equal "body: foo\nbar: baz", mail.body.decoded end def test_starttls_is_enabled_if_supported -- cgit v1.2.3 From 0e38f5bdccf7465ea05090db2a4a2659aa3012ea Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Sat, 21 Nov 2009 23:55:53 +1100 Subject: 131 tests, 266 assertions, 9 failures, 6 errors --- actionmailer/test/mail_service_test.rb | 12 ++++++------ actionmailer/test/quoting_test.rb | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'actionmailer/test') diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index 6c61bc8c00..cfa4c32b1c 100644 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -708,7 +708,7 @@ The body EOF mail = Mail.new(msg) assert_equal "this == working?", mail.subject.decoded - assert_equal "this == working?", mail.quoted_subject + assert_equal "Subject: this == working?\r\n", mail.subject.encoded end def test_unquote_7bit_body @@ -722,7 +722,7 @@ The=3Dbody EOF mail = Mail.new(msg) assert_equal "The=3Dbody", mail.body.decoded.strip - assert_equal "The=3Dbody", mail.quoted_body.strip + assert_equal "The=3Dbody", mail.body.encoded.strip end def test_unquote_quoted_printable_body @@ -736,7 +736,7 @@ The=3Dbody EOF mail = Mail.new(msg) assert_equal "The=body", mail.body.decoded.strip - assert_equal "The=3Dbody", mail.quoted_body.strip + assert_equal "The=3Dbody", mail.body.encoded.strip end def test_unquote_base64_body @@ -750,7 +750,7 @@ VGhlIGJvZHk= EOF mail = Mail.new(msg) assert_equal "The body", mail.body.decoded.strip - assert_equal "VGhlIGJvZHk=", mail.quoted_body.strip + assert_equal "VGhlIGJvZHk=", mail.body.encoded.strip end def test_extended_headers @@ -823,7 +823,7 @@ EOF 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 @@ -831,7 +831,7 @@ EOF 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 diff --git a/actionmailer/test/quoting_test.rb b/actionmailer/test/quoting_test.rb index 1410712123..5319d2c6e8 100644 --- a/actionmailer/test/quoting_test.rb +++ b/actionmailer/test/quoting_test.rb @@ -6,37 +6,37 @@ class QuotingTest < Test::Unit::TestCase # Move some tests from TMAIL here def test_unquote_quoted_printable a ="=?ISO-8859-1?Q?[166417]_Bekr=E6ftelse_fra_Rejsefeber?=" - b = TMail::Unquoter.unquote_and_convert_to(a, 'utf-8') + b = Mail::Encodings.unquote_and_convert_to(a, 'utf-8') assert_equal "[166417] Bekr\303\246ftelse fra Rejsefeber", b end def test_unquote_base64 a ="=?ISO-8859-1?B?WzE2NjQxN10gQmVrcuZmdGVsc2UgZnJhIFJlanNlZmViZXI=?=" - b = TMail::Unquoter.unquote_and_convert_to(a, 'utf-8') + b = Mail::Encodings.unquote_and_convert_to(a, 'utf-8') assert_equal "[166417] Bekr\303\246ftelse fra Rejsefeber", b end def test_unquote_without_charset a ="[166417]_Bekr=E6ftelse_fra_Rejsefeber" - b = TMail::Unquoter.unquote_and_convert_to(a, 'utf-8') + b = Mail::Encodings.unquote_and_convert_to(a, 'utf-8') assert_equal "[166417]_Bekr=E6ftelse_fra_Rejsefeber", b end def test_unqoute_multiple a ="=?utf-8?q?Re=3A_=5B12=5D_=23137=3A_Inkonsistente_verwendung_von_=22Hin?==?utf-8?b?enVmw7xnZW4i?=" - b = TMail::Unquoter.unquote_and_convert_to(a, 'utf-8') + b = Mail::Encodings.unquote_and_convert_to(a, 'utf-8') assert_equal "Re: [12] #137: Inkonsistente verwendung von \"Hinzuf\303\274gen\"", b end def test_unqoute_in_the_middle a ="Re: Photos =?ISO-8859-1?Q?Brosch=FCre_Rand?=" - b = TMail::Unquoter.unquote_and_convert_to(a, 'utf-8') + b = Mail::Encodings.unquote_and_convert_to(a, 'utf-8') assert_equal "Re: Photos Brosch\303\274re Rand", b end def test_unqoute_iso a ="=?ISO-8859-1?Q?Brosch=FCre_Rand?=" - b = TMail::Unquoter.unquote_and_convert_to(a, 'iso-8859-1') + b = Mail::Encodings.unquote_and_convert_to(a, 'iso-8859-1') expected = "Brosch\374re Rand" expected.force_encoding 'iso-8859-1' if expected.respond_to?(:force_encoding) assert_equal expected, b @@ -57,7 +57,7 @@ class QuotingTest < Test::Unit::TestCase quoted_printable(#{original.inspect}, "UTF-8") CODE - unquoted = TMail::Unquoter.unquote_and_convert_to(result, nil) + unquoted = Mail::Encodings.unquote_and_convert_to(result, nil) assert_equal unquoted, original end -- cgit v1.2.3 From f6f70540bbb77a80df0949d0c9e57239bca10132 Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Sun, 22 Nov 2009 00:04:36 +1100 Subject: Updating tests for Mail gem --- actionmailer/test/mail_helper_test.rb | 2 +- actionmailer/test/mail_service_test.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'actionmailer/test') diff --git a/actionmailer/test/mail_helper_test.rb b/actionmailer/test/mail_helper_test.rb index b750d21f8a..d04215171d 100644 --- a/actionmailer/test/mail_helper_test.rb +++ b/actionmailer/test/mail_helper_test.rb @@ -90,7 +90,7 @@ class MailerHelperTest < Test::Unit::TestCase def test_use_mail_helper mail = HelperMailer.create_use_mail_helper(@recipient) assert_match %r{ But soft!}, mail.encoded - assert_match %r{east, and\n Juliet}, mail.encoded + assert_match %r{east, and\r\n Juliet}, mail.encoded end end diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index cfa4c32b1c..6ed7f20837 100644 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -695,7 +695,7 @@ The body EOF mail = Mail.new(msg) assert_equal "testing testing \326\244", mail.subject.decoded - assert_equal "=?utf-8?Q?testing_testing_=D6=A4?=", mail.quoted_subject + assert_equal "Subject: =?utf-8?Q?testing_testing_=D6=A4?=\r\n", mail.subject.encoded end def test_unquote_7bit_subject -- cgit v1.2.3 From 747d56881a07d4636fbaceb1542579d5e02daddd Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Sun, 22 Nov 2009 23:20:57 +1100 Subject: 131 tests, 309 assertions, 0 failures, 0 errors --- actionmailer/test/mail_service_test.rb | 66 +++++++++++++++++++--------------- actionmailer/test/test_helper_test.rb | 8 ++--- actionmailer/test/tmail_test.rb | 11 +++--- 3 files changed, 47 insertions(+), 38 deletions(-) (limited to 'actionmailer/test') diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index 6ed7f20837..c4d664d7e5 100644 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -232,7 +232,7 @@ class TestMailer < ActionMailer::Base p.part :content_type => "text/html", :body => "test HTML
\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) @@ -346,36 +346,38 @@ 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 "test HTML
", created.parts.first.parts.second.body.decoded end def test_attachment_with_custom_header created = nil assert_nothing_raised { created = TestMailer.create_attachment_with_custom_header(@recipient) } - created.encoded assert created.parts.any? { |p| p.header['content-id'].to_s == "" } end @@ -817,7 +819,7 @@ EOF created = TestMailer.create_utf8_body @recipient assert_match(/\nFrom: =\?utf-8\?Q\?Foo_.*?\?= \r/, created.encoded) - assert_match(/\nTo: =\?utf-8\?Q\?Foo_.*?\?= , Example Recipient , \r\n\tExample Recipient }, 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 diff --git a/actionmailer/test/test_helper_test.rb b/actionmailer/test/test_helper_test.rb index 92527dcef9..8e4254411c 100644 --- a/actionmailer/test/test_helper_test.rb +++ b/actionmailer/test/test_helper_test.rb @@ -18,9 +18,9 @@ class TestHelperMailerTest < ActionMailer::TestCase end def test_setup_creates_the_expected_mailer - assert @expected.is_a?(Mail) - assert_equal "1.0", @expected.mime_version - assert_equal "text/plain", @expected.content_type + assert @expected.is_a?(Mail::Message) + assert_equal "1.0", @expected.mime_version.version + assert_equal "text/plain", @expected.content_type.string end def test_mailer_class_is_correctly_inferred @@ -125,7 +125,7 @@ class AnotherTestHelperMailerTest < ActionMailer::TestCase end def test_setup_shouldnt_conflict_with_mailer_setup - assert @expected.is_a?(Mail) + assert @expected.is_a?(Mail::Message) assert_equal 'a value', @test_var end end diff --git a/actionmailer/test/tmail_test.rb b/actionmailer/test/tmail_test.rb index 2a3f2a9e55..5d895f3790 100644 --- a/actionmailer/test/tmail_test.rb +++ b/actionmailer/test/tmail_test.rb @@ -4,10 +4,10 @@ class TMailMailTest < Test::Unit::TestCase def test_body m = Mail.new expected = 'something_with_underscores' - m.encoding = 'quoted-printable' + m.content_transfer_encoding = 'quoted-printable' quoted_body = [expected].pack('*M') m.body = quoted_body - assert_equal "something_with_underscores=\n", m.quoted_body + assert_equal "something_with_underscores=\r\n", m.body.encoded # CHANGED: body returns object, not string, Changed m.body to m.body.decoded assert_equal expected, m.body.decoded end @@ -16,8 +16,9 @@ class TMailMailTest < Test::Unit::TestCase fixture = File.read("#{File.dirname(__FILE__)}/fixtures/raw_email_with_nested_attachment") mail = Mail.new(fixture) assert_equal 2, mail.attachments.length - assert_equal "image/png", mail.attachments.first.content_type - assert_equal 1902, mail.attachments.first.length - assert_equal "application/pkcs7-signature", mail.attachments.last.content_type + assert_equal "image/png", mail.attachments.first.mime_type + assert_equal 1902, mail.attachments.first.decoded.length + assert_equal "application/pkcs7-signature", mail.attachments.last.mime_type end + end -- cgit v1.2.3 From d98fee67e2d2f12f227bc8c1991f31fb5d8acaa6 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sun, 22 Nov 2009 15:41:29 -0800 Subject: Never require jcode --- actionmailer/test/quoting_test.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'actionmailer/test') diff --git a/actionmailer/test/quoting_test.rb b/actionmailer/test/quoting_test.rb index 5319d2c6e8..4e86d55285 100644 --- a/actionmailer/test/quoting_test.rb +++ b/actionmailer/test/quoting_test.rb @@ -50,7 +50,6 @@ class QuotingTest < Test::Unit::TestCase $:.unshift(File.dirname(__FILE__) + "/../lib/") if RUBY_VERSION < '1.9' $KCODE = 'u' - require 'jcode' end require 'action_mailer/quoting' include ActionMailer::Quoting -- cgit v1.2.3 From cc391c30227564032398f24417bba21ab1a3d66a Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Mon, 23 Nov 2009 20:53:07 +1100 Subject: Deprecating attachment :body => 'string' in favour of attachment :data => 'string' --- actionmailer/test/mail_service_test.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'actionmailer/test') diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index c4d664d7e5..3099dddf87 100644 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -9,7 +9,7 @@ class FunkyPathMailer < ActionMailer::Base subject "This path has dots" from "Chad Fowler " attachment :content_type => "text/plain", - :body => "dots dots dots..." + :data => "dots dots dots..." end end @@ -144,7 +144,7 @@ class TestMailer < ActionMailer::Base end attachment :content_type => "image/jpeg", :filename => File.join(File.dirname(__FILE__), "fixtures", "attachments", "foo.jpg"), - :body => "123456789" + :data => "123456789" render :text => "plain text default" end @@ -232,7 +232,7 @@ class TestMailer < ActionMailer::Base p.part :content_type => "text/html", :body => "test HTML
\nline #2" end - attachment :content_type => "application/octet-stream", :filename => "test.txt", :body => "test abcdefghijklmnopqstuvwxyz" + attachment :content_type => "application/octet-stream", :filename => "test.txt", :data => "test abcdefghijklmnopqstuvwxyz" end def nested_multipart_with_body(recipient) @@ -252,7 +252,7 @@ class TestMailer < ActionMailer::Base from "test@example.com" content_type "multipart/related" 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' => '' } + attachment :content_type => "image/jpeg", :filename => File.join(File.dirname(__FILE__), "fixtures", "attachments", "test.jpg"), :data => "i am not a real picture", :headers => { 'Content-ID' => '' } end def unnamed_attachment(recipient) @@ -261,7 +261,7 @@ class TestMailer < ActionMailer::Base from "test@example.com" content_type "multipart/mixed" part :content_type => "text/plain", :body => "hullo" - attachment :content_type => "application/octet-stream", :body => "test abcdefghijklmnopqstuvwxyz" + attachment :content_type => "application/octet-stream", :data => "test abcdefghijklmnopqstuvwxyz" end def headers_with_nonalpha_chars(recipient) -- cgit v1.2.3 From 906e308220785b0c57c78462b05eb1552387a9b8 Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Mon, 23 Nov 2009 20:58:22 +1100 Subject: Fixed up incompatible encoding problem for Ruby 1.9 in test suite --- actionmailer/test/mail_service_test.rb | 12 +++++++++--- actionmailer/test/quoting_test.rb | 4 ++++ 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'actionmailer/test') diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index 3099dddf87..c49657acd7 100644 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -1020,9 +1020,15 @@ EOF attachment = mail.attachments.last expected = "01 Quien Te Dij\212at. Pitbull.mp3" - expected.force_encoding(Encoding::ASCII_8BIT) if expected.respond_to?(:force_encoding) - - assert_equal expected, attachment.original_filename + + if expected.respond_to?(:force_encoding) + result = attachment.original_filename.dup + expected.force_encoding(Encoding::ASCII_8BIT) + result.force_encoding(Encoding::ASCII_8BIT) + assert_equal expected, result + else + assert_equal expected, attachment.original_filename + end end def test_decode_message_with_unknown_charset diff --git a/actionmailer/test/quoting_test.rb b/actionmailer/test/quoting_test.rb index 5319d2c6e8..a5deecf263 100644 --- a/actionmailer/test/quoting_test.rb +++ b/actionmailer/test/quoting_test.rb @@ -58,6 +58,10 @@ class QuotingTest < Test::Unit::TestCase CODE unquoted = Mail::Encodings.unquote_and_convert_to(result, nil) + + unquoted.force_encoding(Encoding::ASCII_8BIT) if unquoted.respond_to?(:force_encoding) + original.force_encoding(Encoding::ASCII_8BIT) if original.respond_to?(:force_encoding) + assert_equal unquoted, original end -- cgit v1.2.3 From 7e0aa35c20f06fd9ef245155e30e81cfb38bad05 Mon Sep 17 00:00:00 2001 From: Michael Koziarski Date: Sat, 28 Nov 2009 13:34:05 +1300 Subject: avoid generating invalid SMTP commands in ruby pre 1.9 Signed-off-by: Michael Koziarski Conflicts: actionmailer/lib/action_mailer/base.rb --- actionmailer/test/mail_service_test.rb | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'actionmailer/test') diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index c98f0a7601..697265b8ec 100644 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -31,6 +31,18 @@ class TestMailer < ActionMailer::Base render :text => "Goodbye, Mr. #{recipient}" end + def from_with_name + from "System " + recipients "root@loudthinking.com" + body "Nothing to see here." + end + + def from_without_name + from "system@loudthinking.com" + recipients "root@loudthinking.com" + body "Nothing to see here." + end + def cc_bcc(recipient) recipients recipient subject "testing bcc/cc" @@ -487,6 +499,28 @@ class ActionMailerTest < Test::Unit::TestCase assert_equal expected.encoded, ActionMailer::Base.deliveries.first.encoded end + def test_from_without_name_for_smtp + ActionMailer::Base.delivery_method = :smtp + TestMailer.deliver_from_without_name + + mail = MockSMTP.deliveries.first + assert_not_nil mail + mail, from, to = mail + + assert_equal 'system@loudthinking.com', from.to_s + end + + def test_from_with_name_for_smtp + ActionMailer::Base.delivery_method = :smtp + TestMailer.deliver_from_with_name + + mail = MockSMTP.deliveries.first + assert_not_nil mail + mail, from, to = mail + + assert_equal 'system@loudthinking.com', from.to_s + end + def test_reply_to expected = new_mail -- cgit v1.2.3 From 6ac32a83283f46b55675ddf4ecab6c91f6f8abde Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Sun, 29 Nov 2009 18:28:45 -0600 Subject: Define a welcome controller in mailer tests --- actionmailer/test/url_test.rb | 44 +++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'actionmailer/test') diff --git a/actionmailer/test/url_test.rb b/actionmailer/test/url_test.rb index 2224f6321c..18eb355e7d 100644 --- a/actionmailer/test/url_test.rb +++ b/actionmailer/test/url_test.rb @@ -1,7 +1,9 @@ require 'abstract_unit' -class TestMailer < ActionMailer::Base +class WelcomeController < ActionController::Base +end +class TestMailer < ActionMailer::Base default_url_options[:host] = 'www.basecamphq.com' def signed_up_with_url(recipient) @@ -52,27 +54,25 @@ class ActionMailerUrlTest < Test::Unit::TestCase end def test_signed_up_with_url - ActionController::Routing.use_controllers! ['welcome'] do - ActionController::Routing::Routes.draw do |map| - map.connect ':controller/:action/:id' - map.welcome 'welcome', :controller=>"foo", :action=>"bar" - end - - expected = new_mail - expected.to = @recipient - expected.subject = "[Signed up] Welcome #{@recipient}" - expected.body = "Hello there, \n\nMr. #{@recipient}. Please see our greeting at http://example.com/welcome/greeting http://www.basecamphq.com/welcome\n\n\"Somelogo\"" - expected.from = "system@loudthinking.com" - expected.date = Time.local(2004, 12, 12) - - created = nil - assert_nothing_raised { created = TestMailer.create_signed_up_with_url(@recipient) } - assert_not_nil created - assert_equal expected.encoded, created.encoded - - assert_nothing_raised { TestMailer.deliver_signed_up_with_url(@recipient) } - assert_not_nil ActionMailer::Base.deliveries.first - assert_equal expected.encoded, ActionMailer::Base.deliveries.first.encoded + ActionController::Routing::Routes.draw do |map| + map.connect ':controller/:action/:id' + map.welcome 'welcome', :controller=>"foo", :action=>"bar" end + + expected = new_mail + expected.to = @recipient + expected.subject = "[Signed up] Welcome #{@recipient}" + expected.body = "Hello there, \n\nMr. #{@recipient}. Please see our greeting at http://example.com/welcome/greeting http://www.basecamphq.com/welcome\n\n\"Somelogo\"" + expected.from = "system@loudthinking.com" + expected.date = Time.local(2004, 12, 12) + + created = nil + assert_nothing_raised { created = TestMailer.create_signed_up_with_url(@recipient) } + assert_not_nil created + assert_equal expected.encoded, created.encoded + + assert_nothing_raised { TestMailer.deliver_signed_up_with_url(@recipient) } + assert_not_nil ActionMailer::Base.deliveries.first + assert_equal expected.encoded, ActionMailer::Base.deliveries.first.encoded end end -- cgit v1.2.3 From 7ee5843c3cedfe36a680d5b28aa31eef45296c50 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Wed, 16 Dec 2009 11:56:51 -0600 Subject: Fully expand relative rails framework paths and make sure we aren't adding any to the load path more than once. --- actionmailer/test/abstract_unit.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'actionmailer/test') diff --git a/actionmailer/test/abstract_unit.rb b/actionmailer/test/abstract_unit.rb index e84b3b0d23..af6f1bc92e 100644 --- a/actionmailer/test/abstract_unit.rb +++ b/actionmailer/test/abstract_unit.rb @@ -1,12 +1,9 @@ -root = File.expand_path('../../..', __FILE__) begin - require "#{root}/vendor/gems/environment" + require File.expand_path('../../../vendor/gems/environment', __FILE__) rescue LoadError - $:.unshift("#{root}/activesupport/lib") - $:.unshift("#{root}/actionpack/lib") end -lib = File.expand_path("#{File.dirname(__FILE__)}/../lib") +lib = File.expand_path('../../lib', __FILE__) $:.unshift(lib) unless $:.include?('lib') || $:.include?(lib) require 'rubygems' -- cgit v1.2.3 From 418639b4cfe477d7309fa53e8b8e2472b44bda80 Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Thu, 17 Dec 2009 12:00:32 +1100 Subject: Fixes for working with 1.9.1-head --- actionmailer/test/mail_service_test.rb | 4 ++-- actionmailer/test/url_test.rb | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'actionmailer/test') diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index dd8307a834..122c20a308 100644 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -534,7 +534,7 @@ class ActionMailerTest < Test::Unit::TestCase assert_not_nil mail mail, from, to = mail - assert_equal 'system@loudthinking.com', from.to_s + assert_equal 'system@loudthinking.com', from.decoded end def test_from_with_name_for_smtp @@ -545,7 +545,7 @@ class ActionMailerTest < Test::Unit::TestCase assert_not_nil mail mail, from, to = mail - assert_equal 'system@loudthinking.com', from.to_s + assert_equal 'system@loudthinking.com', from.addresses.first end def test_reply_to diff --git a/actionmailer/test/url_test.rb b/actionmailer/test/url_test.rb index 0e565b95e8..6334466a92 100644 --- a/actionmailer/test/url_test.rb +++ b/actionmailer/test/url_test.rb @@ -69,10 +69,16 @@ class ActionMailerUrlTest < Test::Unit::TestCase created = nil assert_nothing_raised { created = TestMailer.create_signed_up_with_url(@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_with_url(@recipient) } assert_not_nil ActionMailer::Base.deliveries.first - assert_equal expected.encoded, ActionMailer::Base.deliveries.first.encoded + delivered = ActionMailer::Base.deliveries.first + + delivered.message_id = '<123@456>' + assert_equal expected.encoded, delivered.encoded end end -- cgit v1.2.3 From 63b124b043dec036403f9a88aeafdf99669064e0 Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Thu, 17 Dec 2009 12:23:08 +1100 Subject: Merged in latest changes from rails/master --- actionmailer/test/mail_helper_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionmailer/test') diff --git a/actionmailer/test/mail_helper_test.rb b/actionmailer/test/mail_helper_test.rb index d04215171d..2d3565d159 100644 --- a/actionmailer/test/mail_helper_test.rb +++ b/actionmailer/test/mail_helper_test.rb @@ -56,7 +56,7 @@ end class MailerHelperTest < Test::Unit::TestCase def new_mail( charset="utf-8" ) mail = Mail.new - mail.content_type(["text", "plain", { "charset" => charset }]) + mail.set_content_type "text", "plain", { "charset" => charset } if charset mail end -- cgit v1.2.3 From 4964d3b02cd5c87d821ab7d41d243154c727185d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 22 Dec 2009 20:17:27 +0100 Subject: Make ActionMailer::Base inherit from AbstractController::Base Signed-off-by: Yehuda Katz --- actionmailer/test/mail_service_test.rb | 8 +++++--- actionmailer/test/url_test.rb | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'actionmailer/test') diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index 697265b8ec..1cd3bc77c4 100644 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -34,13 +34,13 @@ class TestMailer < ActionMailer::Base def from_with_name from "System " recipients "root@loudthinking.com" - body "Nothing to see here." + render :text => "Nothing to see here." end def from_without_name from "system@loudthinking.com" recipients "root@loudthinking.com" - body "Nothing to see here." + render :text => "Nothing to see here." end def cc_bcc(recipient) @@ -301,6 +301,7 @@ class TestMailer < ActionMailer::Base render :text => "testing" end + # This tests body calls accepeting a hash, which is deprecated. def body_ivar(recipient) recipients recipient subject "Body as a local variable" @@ -1043,7 +1044,8 @@ EOF end def test_body_is_stored_as_an_ivar - mail = TestMailer.create_body_ivar(@recipient) + mail = nil + ActiveSupport::Deprecation.silence { mail = TestMailer.create_body_ivar(@recipient) } assert_equal "body: foo\nbar: baz", mail.body end diff --git a/actionmailer/test/url_test.rb b/actionmailer/test/url_test.rb index 18eb355e7d..1140613132 100644 --- a/actionmailer/test/url_test.rb +++ b/actionmailer/test/url_test.rb @@ -12,8 +12,8 @@ class TestMailer < ActionMailer::Base @from = "system@loudthinking.com" @sent_on = Time.local(2004, 12, 12) - @body["recipient"] = recipient - @body["welcome_url"] = url_for :host => "example.com", :controller => "welcome", :action => "greeting" + @recipient = recipient + @welcome_url = url_for :host => "example.com", :controller => "welcome", :action => "greeting" end class < Date: Fri, 25 Dec 2009 21:35:40 +0100 Subject: adv_attr_accessors in ActionMailer are not sent to the views, use the mailer object if you need to access the subject, recipients, from, etc. --- actionmailer/test/adv_attr_test.rb | 32 +++++++++++++++++++++++++------- actionmailer/test/mail_render_test.rb | 25 +++++++++++++++++++++---- 2 files changed, 46 insertions(+), 11 deletions(-) (limited to 'actionmailer/test') diff --git a/actionmailer/test/adv_attr_test.rb b/actionmailer/test/adv_attr_test.rb index fd909a5627..f22d733bc5 100644 --- a/actionmailer/test/adv_attr_test.rb +++ b/actionmailer/test/adv_attr_test.rb @@ -1,18 +1,36 @@ require 'abstract_unit' require 'action_mailer/adv_attr_accessor' -class AdvAttrTest < Test::Unit::TestCase +class AdvAttrTest < ActiveSupport::TestCase class Person - include ActionMailer::AdvAttrAccessor + cattr_reader :protected_instance_variables + @@protected_instance_variables = [] + + extend ActionMailer::AdvAttrAccessor adv_attr_accessor :name end + def setup + @person = Person.new + end + def test_adv_attr - bob = Person.new - assert_nil bob.name - bob.name 'Bob' - assert_equal 'Bob', bob.name + assert_nil @person.name + @person.name 'Bob' + assert_equal 'Bob', @person.name + end + + def test_adv_attr_writer + assert_nil @person.name + @person.name = 'Bob' + assert_equal 'Bob', @person.name + end + + def test_raise_an_error_with_multiple_args + assert_raise(ArgumentError) { @person.name('x', 'y') } + end - assert_raise(ArgumentError) {bob.name 'x', 'y'} + def test_ivar_is_added_to_protected_instnace_variables + assert Person.protected_instance_variables.include?('@name') end end diff --git a/actionmailer/test/mail_render_test.rb b/actionmailer/test/mail_render_test.rb index 514f7ed798..0e38a0caba 100644 --- a/actionmailer/test/mail_render_test.rb +++ b/actionmailer/test/mail_render_test.rb @@ -40,13 +40,20 @@ class RenderMailer < ActionMailer::Base from "tester@example.com" end - def included_old_subtemplate(recipient) + def mailer_accessor(recipient) recipients recipient - subject "Including another template in the one being rendered" + subject "Mailer Accessor" from "tester@example.com" - @world = "Earth" - render :inline => "Hello, <%= render \"subtemplate\" %>" + render :inline => "Look, <%= mailer.subject %>!" + end + + def no_instance_variable(recipient) + recipients recipient + subject "No Instance Variable" + from "tester@example.com" + + render :inline => "Look, subject.nil? is <%= @subject.nil? %>!" end def initialize_defaults(method_name) @@ -108,6 +115,16 @@ class RenderHelperTest < Test::Unit::TestCase mail = RenderMailer.deliver_included_subtemplate(@recipient) assert_equal "Hey Ho, let's go!", mail.body.strip end + + def test_mailer_accessor + mail = RenderMailer.deliver_mailer_accessor(@recipient) + assert_equal "Look, Mailer Accessor!", mail.body.strip + end + + def test_no_instance_variable + mail = RenderMailer.deliver_no_instance_variable(@recipient) + assert_equal "Look, subject.nil? is true!", mail.body.strip + end end class FirstSecondHelperTest < Test::Unit::TestCase -- cgit v1.2.3 From 4e1fa4912d2777cba980b4a936a89bd63d201614 Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Sun, 27 Dec 2009 18:38:30 +1100 Subject: Updating actionmailer to call :to_s on all field values instead of decoded --- actionmailer/test/mail_service_test.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'actionmailer/test') diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index 122c20a308..3e65c0b012 100644 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -363,7 +363,7 @@ class ActionMailerTest < Test::Unit::TestCase 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_equal "bar", created.parts[0].header['foo'].to_s 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 @@ -425,11 +425,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.decoded + assert_equal "Subject with i18n", ActionMailer::Base.deliveries.first.subject.to_s 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.decoded + assert_equal "New Subject!", ActionMailer::Base.deliveries.last.subject.to_s end def test_custom_template @@ -534,7 +534,7 @@ class ActionMailerTest < Test::Unit::TestCase assert_not_nil mail mail, from, to = mail - assert_equal 'system@loudthinking.com', from.decoded + assert_equal 'system@loudthinking.com', from.to_s end def test_from_with_name_for_smtp @@ -730,7 +730,7 @@ Content-Type: text/plain; charset=iso-8859-1 The body EOF mail = Mail.new(msg) - assert_equal "testing testing \326\244", mail.subject.decoded + assert_equal "testing testing \326\244", mail.subject.to_s assert_equal "Subject: =?utf-8?Q?testing_testing_=D6=A4?=\r\n", mail.subject.encoded end @@ -743,7 +743,7 @@ Content-Type: text/plain; charset=iso-8859-1 The body EOF mail = Mail.new(msg) - assert_equal "this == working?", mail.subject.decoded + assert_equal "this == working?", mail.subject.to_s assert_equal "Subject: this == working?\r\n", mail.subject.encoded end @@ -960,7 +960,7 @@ EOF mail = TestMailer.create_implicitly_multipart_example(@recipient) assert_equal 3, mail.parts.length - assert_equal "1.0", mail.mime_version.decoded + assert_equal "1.0", mail.mime_version.to_s 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 @@ -1108,7 +1108,7 @@ EOF def test_return_path_with_create mail = TestMailer.create_return_path - assert_equal "another@somewhere.test", mail['return-path'].decoded.to_s + assert_equal "another@somewhere.test", mail['return-path'].to_s end def test_return_path_with_deliver -- cgit v1.2.3 From 331d375cc332e9e8a30a7f9e745414769b780c54 Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Sun, 27 Dec 2009 20:56:16 +1100 Subject: Changing body to use :to_s instead of :decoded... better use case --- actionmailer/test/asset_host_test.rb | 6 +++--- actionmailer/test/mail_layout_test.rb | 22 +++++++++++----------- actionmailer/test/mail_render_test.rb | 18 +++++++++--------- actionmailer/test/mail_service_test.rb | 24 ++++++++++++------------ actionmailer/test/quoting_test.rb | 2 +- actionmailer/test/tmail_test.rb | 4 ++-- 6 files changed, 38 insertions(+), 38 deletions(-) (limited to 'actionmailer/test') diff --git a/actionmailer/test/asset_host_test.rb b/actionmailer/test/asset_host_test.rb index 0b74fe8c24..f3383e5608 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 "\"Somelogo\"", mail.body.decoded.strip + assert_equal "\"Somelogo\"", mail.body.to_s.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 "\"Somelogo\"", mail.body.decoded.strip + assert_equal "\"Somelogo\"", mail.body.to_s.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 "\"Somelogo\"", mail.body.decoded.strip + assert_equal "\"Somelogo\"", mail.body.to_s.strip end end \ No newline at end of file diff --git a/actionmailer/test/mail_layout_test.rb b/actionmailer/test/mail_layout_test.rb index 4775545039..84f13a6d3c 100644 --- a/actionmailer/test/mail_layout_test.rb +++ b/actionmailer/test/mail_layout_test.rb @@ -65,7 +65,7 @@ class LayoutMailerTest < Test::Unit::TestCase def test_should_pickup_default_layout mail = AutoLayoutMailer.create_hello(@recipient) - assert_equal "Hello from layout Inside", mail.body.decoded.strip + assert_equal "Hello from layout Inside", mail.body.to_s.strip end def test_should_pickup_multipart_layout @@ -81,7 +81,7 @@ class LayoutMailerTest < Test::Unit::TestCase # 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/plain layout - text/plain multipart", mail.parts.first.body.to_s # CHANGED: content_type returns an object # assert_equal 'text/html', mail.parts.last.content_type @@ -89,7 +89,7 @@ class LayoutMailerTest < Test::Unit::TestCase # 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 + assert_equal "Hello from layout text/html multipart", mail.parts.last.body.to_s end def test_should_pickup_multipartmixed_layout @@ -104,14 +104,14 @@ class LayoutMailerTest < Test::Unit::TestCase assert_equal 'text/plain', mail.parts.first.content_type.string # 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/plain layout - text/plain multipart", mail.parts.first.body.to_s # CHANGED: content_type returns an object # assert_equal 'text/html', mail.parts.last.content_type assert_equal 'text/html', mail.parts.last.content_type.string # 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 + assert_equal "Hello from layout text/html multipart", mail.parts.last.body.to_s end def test_should_fix_multipart_layout @@ -120,30 +120,30 @@ class LayoutMailerTest < Test::Unit::TestCase assert_equal 2, mail.parts.size assert_equal 'text/plain', mail.parts.first.content_type.string - assert_equal "text/plain layout - text/plain multipart", mail.parts.first.body.decoded + assert_equal "text/plain layout - text/plain multipart", mail.parts.first.body.to_s assert_equal 'text/html', mail.parts.last.content_type.string - assert_equal "Hello from layout text/html multipart", mail.parts.last.body.decoded + assert_equal "Hello from layout text/html multipart", mail.parts.last.body.to_s end def test_should_pickup_layout_given_to_render mail = AutoLayoutMailer.create_spam(@recipient) - assert_equal "Spammer layout Hello, Earth", mail.body.decoded.strip + assert_equal "Spammer layout Hello, Earth", mail.body.to_s.strip end def test_should_respect_layout_false mail = AutoLayoutMailer.create_nolayout(@recipient) - assert_equal "Hello, Earth", mail.body.decoded.strip + assert_equal "Hello, Earth", mail.body.to_s.strip end def test_explicit_class_layout mail = ExplicitLayoutMailer.create_signup(@recipient) - assert_equal "Spammer layout We do not spam", mail.body.decoded.strip + assert_equal "Spammer layout We do not spam", mail.body.to_s.strip end def test_explicit_layout_exceptions mail = ExplicitLayoutMailer.create_logout(@recipient) - assert_equal "You logged out", mail.body.decoded.strip + assert_equal "You logged out", mail.body.to_s.strip end end diff --git a/actionmailer/test/mail_render_test.rb b/actionmailer/test/mail_render_test.rb index 3c97ad2a03..047ba0fb41 100644 --- a/actionmailer/test/mail_render_test.rb +++ b/actionmailer/test/mail_render_test.rb @@ -88,35 +88,35 @@ class RenderHelperTest < Test::Unit::TestCase mail = RenderMailer.create_implicit_body(@recipient) # 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 + assert_equal "Hello there, \n\nMr. test@localhost", mail.body.to_s.strip end def test_inline_template mail = RenderMailer.create_inline_template(@recipient) # CHANGED: body returns an object now # assert_equal "Hello, Earth", mail.body.strip - assert_equal "Hello, Earth", mail.body.decoded.strip + assert_equal "Hello, Earth", mail.body.to_s.strip end def test_file_template mail = RenderMailer.create_file_template(@recipient) # 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 + assert_equal "Hello there, \n\nMr. test@localhost", mail.body.to_s.strip end def test_rxml_template mail = RenderMailer.deliver_rxml_template(@recipient) # CHANGED: body returns an object now # assert_equal "\n", mail.body.strip - assert_equal "\n", mail.body.decoded.strip + assert_equal "\n", mail.body.to_s.strip end def test_included_subtemplate mail = RenderMailer.deliver_included_subtemplate(@recipient) # 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 + assert_equal "Hey Ho, let's go!", mail.body.to_s.strip end end @@ -135,12 +135,12 @@ class FirstSecondHelperTest < Test::Unit::TestCase def test_ordering mail = FirstMailer.create_share(@recipient) - assert_equal "first mail", mail.body.decoded.strip + assert_equal "first mail", mail.body.to_s.strip mail = SecondMailer.create_share(@recipient) - assert_equal "second mail", mail.body.decoded.strip + assert_equal "second mail", mail.body.to_s.strip mail = FirstMailer.create_share(@recipient) - assert_equal "first mail", mail.body.decoded.strip + assert_equal "first mail", mail.body.to_s.strip mail = SecondMailer.create_share(@recipient) - assert_equal "second mail", mail.body.decoded.strip + assert_equal "second mail", mail.body.to_s.strip end end diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index 3e65c0b012..0ea4eda35c 100644 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -382,9 +382,9 @@ class ActionMailerTest < Test::Unit::TestCase 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 "Nothing to see here.", created.parts.first.parts.first.body.to_s assert_equal "text/html", created.parts.first.parts.second.content_type.string - assert_equal "test HTML
", created.parts.first.parts.second.body.decoded + assert_equal "test HTML
", created.parts.first.parts.second.body.to_s end def test_attachment_with_custom_header @@ -757,7 +757,7 @@ Content-Transfer-Encoding: 7bit The=3Dbody EOF mail = Mail.new(msg) - assert_equal "The=3Dbody", mail.body.decoded.strip + assert_equal "The=3Dbody", mail.body.to_s.strip assert_equal "The=3Dbody", mail.body.encoded.strip end @@ -771,7 +771,7 @@ Content-Transfer-Encoding: quoted-printable The=3Dbody EOF mail = Mail.new(msg) - assert_equal "The=body", mail.body.decoded.strip + assert_equal "The=body", mail.body.to_s.strip assert_equal "The=3Dbody", mail.body.encoded.strip end @@ -785,7 +785,7 @@ Content-Transfer-Encoding: base64 VGhlIGJvZHk= EOF mail = Mail.new(msg) - assert_equal "The body", mail.body.decoded.strip + assert_equal "The body", mail.body.to_s.strip assert_equal "VGhlIGJvZHk=", mail.body.encoded.strip end @@ -859,7 +859,7 @@ EOF 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.decoded) + assert_match(/Jamis/, TestMailer.received_body.to_s) end def test_receive_attachments @@ -997,19 +997,19 @@ EOF def test_html_mail_with_underscores mail = TestMailer.create_html_mail_with_underscores(@recipient) - assert_equal %{_Google}, mail.body.decoded + assert_equal %{_Google}, mail.body.to_s 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.decoded) + "line #5\n\nline#6\n\nline #7", mail.body.to_s) 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.decoded - assert_equal "

line #1

\n

line #2

\n

line #3

\n

line #4

\n\n", mail.parts[1].body.decoded + assert_equal "line #1\nline #2\nline #3\nline #4\n\n", mail.parts[0].body.to_s + assert_equal "

line #1

\n

line #2

\n

line #3

\n

line #4

\n\n", mail.parts[1].body.to_s assert_equal "line #1\r\nline #2\r\nline #3\r\nline #4\r\n\r\n", mail.parts[0].body.encoded assert_equal "

line #1

\r\n

line #2

\r\n

line #3

\r\n

line #4

\r\n\r\n", mail.parts[1].body.encoded end @@ -1042,7 +1042,7 @@ EOF 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("This is the first part.", mail.parts.first.parts.first.body.to_s) 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) @@ -1120,7 +1120,7 @@ EOF def test_body_is_stored_as_an_ivar mail = TestMailer.create_body_ivar(@recipient) - assert_equal "body: foo\nbar: baz", mail.body.decoded + assert_equal "body: foo\nbar: baz", mail.body.to_s end def test_starttls_is_enabled_if_supported diff --git a/actionmailer/test/quoting_test.rb b/actionmailer/test/quoting_test.rb index a5deecf263..80e2a3482a 100644 --- a/actionmailer/test/quoting_test.rb +++ b/actionmailer/test/quoting_test.rb @@ -72,7 +72,7 @@ class QuotingTest < Test::Unit::TestCase mail = Mail.new(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 + assert_match %r{Elapsed time}, mail.body.to_s end def test_email_with_partially_quoted_subject diff --git a/actionmailer/test/tmail_test.rb b/actionmailer/test/tmail_test.rb index 5d895f3790..bd0190e661 100644 --- a/actionmailer/test/tmail_test.rb +++ b/actionmailer/test/tmail_test.rb @@ -8,8 +8,8 @@ class TMailMailTest < Test::Unit::TestCase quoted_body = [expected].pack('*M') m.body = quoted_body assert_equal "something_with_underscores=\r\n", m.body.encoded - # CHANGED: body returns object, not string, Changed m.body to m.body.decoded - assert_equal expected, m.body.decoded + # CHANGED: body returns object, not string, Changed m.body to m.body.to_s + assert_equal expected, m.body.to_s end def test_nested_attachments_are_recognized_correctly -- cgit v1.2.3 From 4747a9a57ef4af8cd5172c9da5198cd632adce83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sun, 27 Dec 2009 12:18:46 +0100 Subject: Getting rid of some warnings in AM suite. --- actionmailer/test/mail_render_test.rb | 4 +++- actionmailer/test/mail_service_test.rb | 6 +++--- actionmailer/test/mail_test.rb | 24 ++++++++++++++++++++++++ actionmailer/test/test_helper_test.rb | 6 +++--- actionmailer/test/tmail_test.rb | 24 ------------------------ 5 files changed, 33 insertions(+), 31 deletions(-) create mode 100644 actionmailer/test/mail_test.rb delete mode 100644 actionmailer/test/tmail_test.rb (limited to 'actionmailer/test') diff --git a/actionmailer/test/mail_render_test.rb b/actionmailer/test/mail_render_test.rb index 406aa0a116..09ce5e4854 100644 --- a/actionmailer/test/mail_render_test.rb +++ b/actionmailer/test/mail_render_test.rb @@ -53,7 +53,9 @@ class RenderMailer < ActionMailer::Base subject "No Instance Variable" from "tester@example.com" - render :inline => "Look, subject.nil? is <%= @subject.nil? %>!" + silence_warnings do + render :inline => "Look, subject.nil? is <%= @subject.nil? %>!" + end end def initialize_defaults(method_name) diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index 87761185f4..d6ed8594d3 100644 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -239,7 +239,7 @@ class TestMailer < ActionMailer::Base from "test@example.com" content_type "multipart/mixed" - part :content_type => "multipart/alternative", :content_disposition => "inline", :headers => { "foo" => "bar" } do |p| + part :content_type => "multipart/alternative", :content_disposition => "inline", "foo" => "bar" do |p| p.part :content_type => "text/plain", :body => "test text\nline #2" p.part :content_type => "text/html", :body => "test HTML
\nline #2" end @@ -264,7 +264,7 @@ class TestMailer < ActionMailer::Base from "test@example.com" content_type "multipart/related" part :content_type => "text/html", :body => 'yo' - attachment :content_type => "image/jpeg", :filename => File.join(File.dirname(__FILE__), "fixtures", "attachments", "test.jpg"), :data => "i am not a real picture", :headers => { 'Content-ID' => '' } + attachment :content_type => "image/jpeg", :filename => File.join(File.dirname(__FILE__), "fixtures", "attachments", "test.jpg"), :data => "i am not a real picture", 'Content-ID' => '' end def unnamed_attachment(recipient) @@ -1251,6 +1251,6 @@ class RespondToTest < Test::Unit::TestCase RespondToMailer.not_a_method end - assert_match /undefined method.*not_a_method/, error.message + assert_match(/undefined method.*not_a_method/, error.message) end end diff --git a/actionmailer/test/mail_test.rb b/actionmailer/test/mail_test.rb new file mode 100644 index 0000000000..ea6f25d157 --- /dev/null +++ b/actionmailer/test/mail_test.rb @@ -0,0 +1,24 @@ +require 'abstract_unit' + +class MailTest < Test::Unit::TestCase + def test_body + m = Mail.new + expected = 'something_with_underscores' + m.content_transfer_encoding = 'quoted-printable' + quoted_body = [expected].pack('*M') + m.body = quoted_body + assert_equal "something_with_underscores=\r\n", m.body.encoded + # CHANGED: body returns object, not string, Changed m.body to m.body.to_s + assert_equal expected, m.body.to_s + end + + def test_nested_attachments_are_recognized_correctly + fixture = File.read("#{File.dirname(__FILE__)}/fixtures/raw_email_with_nested_attachment") + mail = Mail.new(fixture) + assert_equal 2, mail.attachments.length + assert_equal "image/png", mail.attachments.first.mime_type + assert_equal 1902, mail.attachments.first.decoded.length + assert_equal "application/pkcs7-signature", mail.attachments.last.mime_type + end + +end diff --git a/actionmailer/test/test_helper_test.rb b/actionmailer/test/test_helper_test.rb index 8e4254411c..86d22da9bf 100644 --- a/actionmailer/test/test_helper_test.rb +++ b/actionmailer/test/test_helper_test.rb @@ -92,7 +92,7 @@ class TestHelperMailerTest < ActionMailer::TestCase end end - assert_match /2 .* but 1/, error.message + assert_match(/2 .* but 1/, error.message) end def test_assert_emails_too_many_sent @@ -103,7 +103,7 @@ class TestHelperMailerTest < ActionMailer::TestCase end end - assert_match /1 .* but 2/, error.message + assert_match(/1 .* but 2/, error.message) end def test_assert_no_emails_failure @@ -113,7 +113,7 @@ class TestHelperMailerTest < ActionMailer::TestCase end end - assert_match /0 .* but 1/, error.message + assert_match(/0 .* but 1/, error.message) end end diff --git a/actionmailer/test/tmail_test.rb b/actionmailer/test/tmail_test.rb deleted file mode 100644 index bd0190e661..0000000000 --- a/actionmailer/test/tmail_test.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'abstract_unit' - -class TMailMailTest < Test::Unit::TestCase - def test_body - m = Mail.new - expected = 'something_with_underscores' - m.content_transfer_encoding = 'quoted-printable' - quoted_body = [expected].pack('*M') - m.body = quoted_body - assert_equal "something_with_underscores=\r\n", m.body.encoded - # CHANGED: body returns object, not string, Changed m.body to m.body.to_s - assert_equal expected, m.body.to_s - end - - def test_nested_attachments_are_recognized_correctly - fixture = File.read("#{File.dirname(__FILE__)}/fixtures/raw_email_with_nested_attachment") - mail = Mail.new(fixture) - assert_equal 2, mail.attachments.length - assert_equal "image/png", mail.attachments.first.mime_type - assert_equal 1902, mail.attachments.first.decoded.length - assert_equal "application/pkcs7-signature", mail.attachments.last.mime_type - end - -end -- cgit v1.2.3 From c039bcdb1c94d8b28fc9398d4b88b4453cdd9fb1 Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Mon, 28 Dec 2009 12:25:14 +1100 Subject: Moved sort_parts into Mail, updated mail requirement to 1.4.2 --- actionmailer/test/mail_service_test.rb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'actionmailer/test') diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index d6ed8594d3..bebd8df8e9 100644 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -930,7 +930,6 @@ EOF mail = TestMailer.create_explicitly_multipart_example(@recipient) assert_equal 3, mail.parts.length assert_equal 'multipart/mixed', mail.content_type.string - assert_equal "text/plain", mail.parts[0].content_type.string assert_equal "text/html", mail.parts[1].content_type.string @@ -938,7 +937,6 @@ EOF 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 @@ -963,11 +961,11 @@ EOF assert_equal 3, mail.parts.length assert_equal "1.0", mail.mime_version.to_s assert_equal "multipart/alternative", mail.content_type.string - assert_equal "application/x-yaml", mail.parts[0].content_type.string + assert_equal "text/plain", 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 "text/html", 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 "application/x-yaml", mail.parts[2].content_type.string assert_equal "utf-8", mail.parts[2].charset end @@ -976,9 +974,9 @@ 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.string + assert_equal "application/x-yaml", 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 + assert_equal "text/html", mail.parts[2].content_type.string end def test_implicitly_multipart_messages_with_charset -- cgit v1.2.3 From b354496bda901cb0af499d6f3dff17a96a834a67 Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Mon, 28 Dec 2009 21:41:16 +1100 Subject: Adding default 8bit encoding if the body has non usascii in it --- actionmailer/test/mail_service_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionmailer/test') diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index bebd8df8e9..152900259d 100644 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -107,7 +107,7 @@ class TestMailer < ActionMailer::Base cc "Foo áëô îü " bcc "Foo áëô îü " charset "utf-8" - + render :text => "åœö blah" end -- cgit v1.2.3 From 345e622a20fd14a356a69da40e527075b1117b52 Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Wed, 30 Dec 2009 16:12:51 +1100 Subject: Adding TMailCompat layer for :set_content_type and friends --- actionmailer/test/tmail_compat_test.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 actionmailer/test/tmail_compat_test.rb (limited to 'actionmailer/test') diff --git a/actionmailer/test/tmail_compat_test.rb b/actionmailer/test/tmail_compat_test.rb new file mode 100644 index 0000000000..9b0e91f5f8 --- /dev/null +++ b/actionmailer/test/tmail_compat_test.rb @@ -0,0 +1,14 @@ +require 'abstract_unit' + +class TmailCompatTest < Test::Unit::TestCase + + def test_set_content_type_raises_deprecation_warning + mail = Mail.new + STDERR.expects(:puts) # Deprecation warning + assert_nothing_raised do + mail.set_content_type "text/plain" + end + assert_equal mail.content_type.string, "text/plain" + end + +end -- cgit v1.2.3 From a2880827b4b023a87889138aa39f1182d0265194 Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Wed, 30 Dec 2009 20:43:56 +1100 Subject: Adding :transfer_encoding -> :content_transfer_encoding as part of TmailCompat --- actionmailer/test/tmail_compat_test.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'actionmailer/test') diff --git a/actionmailer/test/tmail_compat_test.rb b/actionmailer/test/tmail_compat_test.rb index 9b0e91f5f8..faa267e3bf 100644 --- a/actionmailer/test/tmail_compat_test.rb +++ b/actionmailer/test/tmail_compat_test.rb @@ -10,5 +10,14 @@ class TmailCompatTest < Test::Unit::TestCase end assert_equal mail.content_type.string, "text/plain" end + + def test_transfer_encoding_raises_deprecation_warning + mail = Mail.new + STDERR.expects(:puts) # Deprecation warning + assert_nothing_raised do + mail.transfer_encoding "base64" + end + assert_equal mail.content_transfer_encoding.value, "base64" + end end -- cgit v1.2.3 From bf6d0e2bc2c839d03d14629572ef48d8b9335cbf Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Sun, 3 Jan 2010 11:15:50 +1100 Subject: Updating to Mail 1.5.0, including default values for all Message#field_name methods, can access field objects by calling Message#[:field_name] --- actionmailer/test/mail_layout_test.rb | 18 +++---- actionmailer/test/mail_service_test.rb | 88 +++++++++++++++++----------------- actionmailer/test/quoting_test.rb | 2 +- actionmailer/test/test_helper_test.rb | 4 +- actionmailer/test/tmail_compat_test.rb | 4 +- 5 files changed, 58 insertions(+), 58 deletions(-) (limited to 'actionmailer/test') diff --git a/actionmailer/test/mail_layout_test.rb b/actionmailer/test/mail_layout_test.rb index 84f13a6d3c..0877e7b2cb 100644 --- a/actionmailer/test/mail_layout_test.rb +++ b/actionmailer/test/mail_layout_test.rb @@ -72,12 +72,12 @@ class LayoutMailerTest < Test::Unit::TestCase mail = AutoLayoutMailer.create_multipart(@recipient) # CHANGED: content_type returns an object # assert_equal "multipart/alternative", mail.content_type - assert_equal "multipart/alternative", mail.content_type.string + assert_equal "multipart/alternative", mail.mime_type assert_equal 2, mail.parts.size # CHANGED: content_type returns an object # assert_equal 'text/plain', mail.parts.first.content_type - assert_equal 'text/plain', mail.parts.first.content_type.string + assert_equal 'text/plain', mail.parts.first.mime_type # CHANGED: body returns an object # assert_equal "text/plain layout - text/plain multipart", mail.parts.first.body @@ -85,7 +85,7 @@ class LayoutMailerTest < Test::Unit::TestCase # CHANGED: content_type returns an object # assert_equal 'text/html', mail.parts.last.content_type - assert_equal 'text/html', mail.parts.last.content_type.string + assert_equal 'text/html', mail.parts.last.mime_type # CHANGED: body returns an object # assert_equal "Hello from layout text/html multipart", mail.parts.last.body @@ -96,19 +96,19 @@ class LayoutMailerTest < Test::Unit::TestCase mail = AutoLayoutMailer.create_multipart(@recipient, "multipart/mixed") # CHANGED: content_type returns an object # assert_equal "multipart/mixed", mail.content_type - assert_equal "multipart/mixed", mail.content_type.string + assert_equal "multipart/mixed", mail.mime_type assert_equal 2, mail.parts.size # CHANGED: content_type returns an object # assert_equal 'text/plain', mail.parts.first.content_type - assert_equal 'text/plain', mail.parts.first.content_type.string + assert_equal 'text/plain', mail.parts.first.mime_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.to_s # CHANGED: content_type returns an object # assert_equal 'text/html', mail.parts.last.content_type - assert_equal 'text/html', mail.parts.last.content_type.string + assert_equal 'text/html', mail.parts.last.mime_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.to_s @@ -116,13 +116,13 @@ class LayoutMailerTest < Test::Unit::TestCase def test_should_fix_multipart_layout mail = AutoLayoutMailer.create_multipart(@recipient, "text/plain") - assert_equal "multipart/alternative", mail.content_type.string + assert_equal "multipart/alternative", mail.mime_type assert_equal 2, mail.parts.size - assert_equal 'text/plain', mail.parts.first.content_type.string + assert_equal 'text/plain', mail.parts.first.mime_type assert_equal "text/plain layout - text/plain multipart", mail.parts.first.body.to_s - assert_equal 'text/html', mail.parts.last.content_type.string + assert_equal 'text/html', mail.parts.last.mime_type assert_equal "Hello from layout text/html multipart", mail.parts.last.body.to_s end diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index 152900259d..f66b4a174b 100644 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -362,13 +362,13 @@ class ActionMailerTest < Test::Unit::TestCase 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 "multipart/mixed", created.mime_type + assert_equal "multipart/alternative", created.parts[0].mime_type assert_equal "bar", created.parts[0].header['foo'].to_s 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 + assert_equal "text/plain", created.parts[0].parts[0].mime_type + assert_equal "text/html", created.parts[0].parts[1].mime_type + assert_equal "application/octet-stream", created.parts[1].mime_type end @@ -380,11 +380,11 @@ class ActionMailerTest < Test::Unit::TestCase assert_equal 1,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.first.content_type.string - assert_equal "text/plain", created.parts.first.parts.first.content_type.string + assert_equal "multipart/mixed", created.mime_type + assert_equal "multipart/alternative", created.parts.first.mime_type + assert_equal "text/plain", created.parts.first.parts.first.mime_type assert_equal "Nothing to see here.", created.parts.first.parts.first.body.to_s - assert_equal "text/html", created.parts.first.parts.second.content_type.string + assert_equal "text/html", created.parts.first.parts.second.mime_type assert_equal "test HTML
", created.parts.first.parts.second.body.to_s end @@ -468,8 +468,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.string - assert_equal 'text/html', created.parts[1].content_type.string + assert_equal 'text/plain', created.parts[0].mime_type + assert_equal 'text/html', created.parts[1].mime_type end def test_cancelled_account @@ -731,8 +731,8 @@ Content-Type: text/plain; charset=iso-8859-1 The body EOF mail = Mail.new(msg) - assert_equal "testing testing \326\244", mail.subject.to_s - assert_equal "Subject: =?utf-8?Q?testing_testing_=D6=A4?=\r\n", mail.subject.encoded + assert_equal "testing testing \326\244", mail.subject + assert_equal "Subject: =?utf-8?Q?testing_testing_=D6=A4?=\r\n", mail[:subject].encoded end def test_unquote_7bit_subject @@ -744,8 +744,8 @@ Content-Type: text/plain; charset=iso-8859-1 The body EOF mail = Mail.new(msg) - assert_equal "this == working?", mail.subject.to_s - assert_equal "Subject: this == working?\r\n", mail.subject.encoded + assert_equal "this == working?", mail.subject + assert_equal "Subject: this == working?\r\n", mail[:subject].encoded end def test_unquote_7bit_body @@ -868,7 +868,7 @@ EOF mail = Mail.new(fixture) attachment = mail.attachments.last assert_equal "smime.p7s", attachment.original_filename - assert_equal "application/pkcs7-signature", mail.parts.last.content_type.string + assert_equal "application/pkcs7-signature", mail.parts.last.mime_type end def test_decode_attachment_without_charset @@ -913,7 +913,7 @@ EOF def test_multipart_with_mime_version mail = TestMailer.create_multipart_with_mime_version(@recipient) - assert_equal "1.1", mail.mime_version.version + assert_equal "1.1", mail.mime_version end def test_multipart_with_utf8_subject @@ -929,29 +929,29 @@ EOF def test_explicitly_multipart_messages mail = TestMailer.create_explicitly_multipart_example(@recipient) assert_equal 3, mail.parts.length - assert_equal 'multipart/mixed', mail.content_type.string - assert_equal "text/plain", mail.parts[0].content_type.string + assert_equal 'multipart/mixed', mail.mime_type + assert_equal "text/plain", mail.parts[0].mime_type - assert_equal "text/html", mail.parts[1].content_type.string + assert_equal "text/html", mail.parts[1].mime_type 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_equal "image/jpeg", mail.parts[2].mime_type + 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.string + assert_equal "multipart/alternative", mail.mime_type 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_equal 'multipart/mixed', mail.content_type.string + assert_equal 'multipart/mixed', mail.mime_type end def test_implicitly_multipart_messages @@ -960,12 +960,12 @@ EOF mail = TestMailer.create_implicitly_multipart_example(@recipient) assert_equal 3, mail.parts.length assert_equal "1.0", mail.mime_version.to_s - assert_equal "multipart/alternative", mail.content_type.string - assert_equal "text/plain", mail.parts[0].content_type.string + assert_equal "multipart/alternative", mail.mime_type + assert_equal "text/plain", mail.parts[0].mime_type assert_equal "utf-8", mail.parts[0].charset - assert_equal "text/html", mail.parts[1].content_type.string + assert_equal "text/html", mail.parts[1].mime_type assert_equal "utf-8", mail.parts[1].charset - assert_equal "application/x-yaml", mail.parts[2].content_type.string + assert_equal "application/x-yaml", mail.parts[2].mime_type assert_equal "utf-8", mail.parts[2].charset end @@ -974,9 +974,9 @@ EOF mail = TestMailer.create_implicitly_multipart_example(@recipient, nil, ["application/x-yaml", "text/plain"]) assert_equal 3, mail.parts.length - assert_equal "application/x-yaml", mail.parts[0].content_type.string - assert_equal "text/plain", mail.parts[1].content_type.string - assert_equal "text/html", mail.parts[2].content_type.string + assert_equal "application/x-yaml", mail.parts[0].mime_type + assert_equal "text/plain", mail.parts[1].mime_type + assert_equal "text/html", mail.parts[2].mime_type end def test_implicitly_multipart_messages_with_charset @@ -984,14 +984,14 @@ EOF assert_equal "multipart/alternative", mail.header['content-type'].content_type - 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] + 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.string + assert_equal "text/html", mail.mime_type end def test_html_mail_with_underscores @@ -1043,7 +1043,7 @@ EOF assert_equal(4, mail.parts.first.parts.length) assert_equal("This is the first part.", mail.parts.first.parts.first.body.to_s) assert_equal("test.rb", mail.parts.first.parts.second.filename) - assert_equal("flowed", mail.parts.first.parts.fourth.content_type.parameters[:format]) + assert_equal("flowed", mail.parts.first.parts.fourth.content_type_parameters[:format]) assert_equal('smime.p7s', mail.parts.second.filename) end @@ -1081,9 +1081,9 @@ EOF assert !mail.from_addrs.empty? assert !mail.cc_addrs.empty? assert !mail.bcc_addrs.empty? - assert_match(/:/, mail.from_addrs.to_s) - assert_match(/:/, mail.cc_addrs.to_s) - assert_match(/:/, mail.bcc_addrs.to_s) + assert_match(/:/, mail[:from].decoded) + assert_match(/:/, mail[:cc].decoded) + assert_match(/:/, mail[:bcc].decoded) end def test_deliver_with_mail_object @@ -1095,14 +1095,14 @@ 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.string + assert "text/plain", mail.parts[1].mime_type 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.encoded - assert_match %r{charset="utf-8"}, mail.content_type.encoded + assert_match %r{format=flowed}, mail.content_type + assert_match %r{charset=utf-8}, mail.content_type end def test_return_path_with_create diff --git a/actionmailer/test/quoting_test.rb b/actionmailer/test/quoting_test.rb index b16d160805..7640f4b086 100644 --- a/actionmailer/test/quoting_test.rb +++ b/actionmailer/test/quoting_test.rb @@ -78,7 +78,7 @@ class QuotingTest < Test::Unit::TestCase mail = Mail.new(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 + assert_equal "Re: Test: \"\346\274\242\345\255\227\" mid \"\346\274\242\345\255\227\" tail", mail.subject end private diff --git a/actionmailer/test/test_helper_test.rb b/actionmailer/test/test_helper_test.rb index 86d22da9bf..1fed26f78f 100644 --- a/actionmailer/test/test_helper_test.rb +++ b/actionmailer/test/test_helper_test.rb @@ -19,8 +19,8 @@ class TestHelperMailerTest < ActionMailer::TestCase def test_setup_creates_the_expected_mailer assert @expected.is_a?(Mail::Message) - assert_equal "1.0", @expected.mime_version.version - assert_equal "text/plain", @expected.content_type.string + assert_equal "1.0", @expected.mime_version + assert_equal "text/plain", @expected.mime_type end def test_mailer_class_is_correctly_inferred diff --git a/actionmailer/test/tmail_compat_test.rb b/actionmailer/test/tmail_compat_test.rb index faa267e3bf..a1ca6a7243 100644 --- a/actionmailer/test/tmail_compat_test.rb +++ b/actionmailer/test/tmail_compat_test.rb @@ -8,7 +8,7 @@ class TmailCompatTest < Test::Unit::TestCase assert_nothing_raised do mail.set_content_type "text/plain" end - assert_equal mail.content_type.string, "text/plain" + assert_equal mail.mime_type, "text/plain" end def test_transfer_encoding_raises_deprecation_warning @@ -17,7 +17,7 @@ class TmailCompatTest < Test::Unit::TestCase assert_nothing_raised do mail.transfer_encoding "base64" end - assert_equal mail.content_transfer_encoding.value, "base64" + assert_equal mail.content_transfer_encoding, "base64" end end -- cgit v1.2.3