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