mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Changing body to use :to_s instead of :decoded... better use case
This commit is contained in:
@@ -55,5 +55,5 @@ module Net
|
||||
end
|
||||
|
||||
|
||||
gem 'mail', '>= 1.3.5'
|
||||
gem 'mail', '>= 1.4.0'
|
||||
require 'mail'
|
||||
|
||||
@@ -24,7 +24,7 @@ class AssetHostTest < Test::Unit::TestCase
|
||||
def test_asset_host_as_string
|
||||
ActionController::Base.asset_host = "http://www.example.com"
|
||||
mail = AssetHostMailer.deliver_email_with_asset(@recipient)
|
||||
assert_equal "<img alt=\"Somelogo\" src=\"http://www.example.com/images/somelogo.png\" />", mail.body.decoded.strip
|
||||
assert_equal "<img alt=\"Somelogo\" src=\"http://www.example.com/images/somelogo.png\" />", 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 "<img alt=\"Somelogo\" src=\"http://images.example.com/images/somelogo.png\" />", mail.body.decoded.strip
|
||||
assert_equal "<img alt=\"Somelogo\" src=\"http://images.example.com/images/somelogo.png\" />", 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 "<img alt=\"Somelogo\" src=\"http://www.example.com/images/somelogo.png\" />", mail.body.decoded.strip
|
||||
assert_equal "<img alt=\"Somelogo\" src=\"http://www.example.com/images/somelogo.png\" />", mail.body.to_s.strip
|
||||
end
|
||||
end
|
||||
@@ -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
|
||||
|
||||
@@ -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 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<test/>", mail.body.strip
|
||||
assert_equal "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<test/>", mail.body.decoded.strip
|
||||
assert_equal "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<test/>", 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
|
||||
|
||||
@@ -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 "<b>test</b> HTML<br/>", created.parts.first.parts.second.body.decoded
|
||||
assert_equal "<b>test</b> HTML<br/>", 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 %{<a href="http://google.com" target="_blank">_Google</a>}, mail.body.decoded
|
||||
assert_equal %{<a href="http://google.com" target="_blank">_Google</a>}, 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 "<p>line #1</p>\n<p>line #2</p>\n<p>line #3</p>\n<p>line #4</p>\n\n", mail.parts[1].body.decoded
|
||||
assert_equal "line #1\nline #2\nline #3\nline #4\n\n", mail.parts[0].body.to_s
|
||||
assert_equal "<p>line #1</p>\n<p>line #2</p>\n<p>line #3</p>\n<p>line #4</p>\n\n", mail.parts[1].body.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 "<p>line #1</p>\r\n<p>line #2</p>\r\n<p>line #3</p>\r\n<p>line #4</p>\r\n\r\n", mail.parts[1].body.encoded
|
||||
end
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user