Permalink
Browse files

Fix mail tests on Rails 4.2

An update to mail broke some tests on Rails. Originally they were
unblocked here #31026 but Jeremy fixed them for Mail 2.7 in
0931e17.

I wasn't able to cleanly backport this so I'm doing it manually. Fixes
the failing Rails 4.2 build on travis.
  • Loading branch information...
eileencodes committed Dec 7, 2017
1 parent 718d739 commit b8935e479dd2d2c8fc0a4b2a89802e214f1580f6
Showing with 19 additions and 19 deletions.
  1. +3 −2 Gemfile.lock
  2. +15 −16 actionmailer/test/base_test.rb
  3. +1 −1 actionmailer/test/test_helper_test.rb
View
@@ -134,10 +134,11 @@ GEM
nokogiri
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.6)
mime-types (>= 1.16, < 4)
mail (2.7.0)
mini_mime (>= 0.1.1)
metaclass (0.0.4)
mime-types (2.99.3)
mini_mime (1.0.0)
mini_portile2 (2.2.0)
minitest (5.3.3)
mocha (0.14.0)
@@ -316,22 +316,21 @@ def welcome
test "implicit multipart with attachments creates nested parts" do
email = BaseMailer.implicit_multipart(attachments: true)
assert_equal("application/pdf", email.parts[0].mime_type)
assert_equal("multipart/alternative", email.parts[1].mime_type)
assert_equal("text/plain", email.parts[1].parts[0].mime_type)
assert_equal("TEXT Implicit Multipart", email.parts[1].parts[0].body.encoded)
assert_equal("text/html", email.parts[1].parts[1].mime_type)
assert_equal("HTML Implicit Multipart", email.parts[1].parts[1].body.encoded)
assert_equal(%w[ application/pdf multipart/alternative ], email.parts.map(&:mime_type).sort)
multipart = email.parts.detect { |p| p.mime_type == "multipart/alternative" }
assert_equal("text/plain", multipart.parts[0].mime_type)
assert_equal("TEXT Implicit Multipart", multipart.parts[0].body.encoded)
assert_equal("text/html", multipart.parts[1].mime_type)
assert_equal("HTML Implicit Multipart", multipart.parts[1].body.encoded)
end
test "implicit multipart with attachments and sort order" do
order = ["text/html", "text/plain"]
with_default BaseMailer, parts_order: order do
email = BaseMailer.implicit_multipart(attachments: true)
assert_equal("application/pdf", email.parts[0].mime_type)
assert_equal("multipart/alternative", email.parts[1].mime_type)
assert_equal("text/plain", email.parts[1].parts[1].mime_type)
assert_equal("text/html", email.parts[1].parts[0].mime_type)
assert_equal(%w[ application/pdf multipart/alternative ], email.parts.map(&:mime_type).sort)
multipart = email.parts.detect { |p| p.mime_type == "multipart/alternative" }
assert_equal(%w[ text/html text/plain ], multipart.parts.map(&:mime_type).sort)
end
end
@@ -397,12 +396,12 @@ def welcome
test "explicit multipart with attachments creates nested parts" do
email = BaseMailer.explicit_multipart(attachments: true)
assert_equal("application/pdf", email.parts[0].mime_type)
assert_equal("multipart/alternative", email.parts[1].mime_type)
assert_equal("text/plain", email.parts[1].parts[0].mime_type)
assert_equal("TEXT Explicit Multipart", email.parts[1].parts[0].body.encoded)
assert_equal("text/html", email.parts[1].parts[1].mime_type)
assert_equal("HTML Explicit Multipart", email.parts[1].parts[1].body.encoded)
assert_equal(%w[ application/pdf multipart/alternative ], email.parts.map(&:mime_type).sort)
multipart = email.parts.detect { |p| p.mime_type == "multipart/alternative" }
assert_equal("text/plain", multipart.parts[0].mime_type)
assert_equal("TEXT Explicit Multipart", multipart.parts[0].body.encoded)
assert_equal("text/html", multipart.parts[1].mime_type)
assert_equal("HTML Explicit Multipart", multipart.parts[1].body.encoded)
end
test "explicit multipart with templates" do
@@ -38,7 +38,7 @@ def test_charset_is_utf_8
end
def test_encode
assert_equal '=?UTF-8?Q?This_is_=E3=81=82_string?=', encode('This is あ string')
assert_equal "This is あ string", Mail::Encodings.q_value_decode(encode("This is あ string"))
end
def test_read_fixture

0 comments on commit b8935e4

Please sign in to comment.