From dbcf01e6310bf3dc72499beb8f4161fb82143388 Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Thu, 8 Apr 2010 12:47:17 +1000 Subject: Removing quoting.rb, upgrade to 2.1.3.6, changing all utf-8 references to UTF-8, updating tests where incorrect encoding --- actionmailer/test/old_base/mail_service_test.rb | 81 ++++++++++++++----------- 1 file changed, 44 insertions(+), 37 deletions(-) (limited to 'actionmailer/test/old_base/mail_service_test.rb') diff --git a/actionmailer/test/old_base/mail_service_test.rb b/actionmailer/test/old_base/mail_service_test.rb index 9eb067554f..b584245cb2 100644 --- a/actionmailer/test/old_base/mail_service_test.rb +++ b/actionmailer/test/old_base/mail_service_test.rb @@ -105,7 +105,7 @@ class TestMailer < ActionMailer::Base sent_on Time.local(2004, 12, 12) cc "Foo áëô îü " bcc "Foo áëô îü " - charset "utf-8" + charset "UTF-8" body "åœö blah" end @@ -131,7 +131,7 @@ class TestMailer < ActionMailer::Base recipients recipient subject "Foo áëô îü" from "test@example.com" - charset "utf-8" + charset "UTF-8" part "text/plain" do |p| p.body = "blah" @@ -316,18 +316,15 @@ class TestMailer < ActionMailer::Base end class ActionMailerTest < Test::Unit::TestCase - include ActionMailer::Quoting - def encode( text, charset="utf-8" ) - quoted_printable( text, charset ) + def encode( text, charset="UTF-8" ) + Mail::Encodings.q_value_encode( text, charset ) end - def new_mail( charset="utf-8" ) + def new_mail( charset="UTF-8" ) mail = Mail.new + mail.charset = charset mail.mime_version = "1.0" - if charset - mail.content_type ["text", "plain", { "charset" => charset }] - end mail end @@ -671,14 +668,14 @@ class ActionMailerTest < Test::Unit::TestCase def test_unquote_quoted_printable_subject msg = <", "iso-8859-1" - expected.cc = quote_address_if_necessary "Grytøyr ", "iso-8859-1" - expected.bcc = quote_address_if_necessary "Grytøyr ", "iso-8859-1" + expected.from = "Grytøyr " + expected.cc = "Grytøyr " + expected.bcc = "Grytøyr " expected.date = Time.local 2004, 12, 12 created = nil @@ -774,13 +771,13 @@ EOF def test_utf8_body_is_not_quoted @recipient = "Foo áëô îü " - expected = new_mail "utf-8" - expected.to = quote_address_if_necessary @recipient, "utf-8" - expected.subject = "testing utf-8 body" + expected = new_mail "UTF-8" + expected.to = @recipient + expected.subject = "testing UTF-8 body" expected.body = "åœö blah" - expected.from = quote_address_if_necessary @recipient, "utf-8" - expected.cc = quote_address_if_necessary @recipient, "utf-8" - expected.bcc = quote_address_if_necessary @recipient, "utf-8" + expected.from = @recipient + expected.cc = @recipient + expected.bcc = @recipient expected.date = Time.local 2004, 12, 12 created = TestMailer.utf8_body @recipient @@ -789,18 +786,21 @@ EOF def test_multiple_utf8_recipients @recipient = ["\"Foo áëô îü\" ", "\"Example Recipient\" "] - expected = new_mail "utf-8" - expected.to = quote_address_if_necessary @recipient, "utf-8" - expected.subject = "testing utf-8 body" + expected = new_mail "UTF-8" + expected.to = @recipient + expected.subject = "testing UTF-8 body" expected.body = "åœö blah" - expected.from = quote_address_if_necessary @recipient.first, "utf-8" - expected.cc = quote_address_if_necessary @recipient, "utf-8" - expected.bcc = quote_address_if_necessary @recipient, "utf-8" + expected.from = @recipient.first + expected.cc = @recipient + expected.bcc = @recipient expected.date = Time.local 2004, 12, 12 created = TestMailer.utf8_body @recipient - assert_match(/\nFrom: =\?utf-8\?Q\?Foo_.*?\?= \r/, created.encoded) - assert_match(/\nTo: =\?utf-8\?Q\?Foo_.*?\?= , \r\n\tExample Recipient ") + assert_match(/#{to_regexp}/m, created.encoded) end def test_receive_decodes_base64_encoded_mail @@ -864,12 +864,19 @@ EOF def test_multipart_with_utf8_subject mail = TestMailer.multipart_with_utf8_subject(@recipient) - assert_match(/\nSubject: =\?utf-8\?Q\?Foo_.*?\?=/, mail.encoded) + regex = Regexp.escape('Subject: =?UTF-8?Q?Foo_=C3=A1=C3=AB=C3=B4_=C3=AE=C3=BC=?=') + assert_match(/#{regex}/, mail.encoded) + string = "Foo áëô îü" + string.force_encoding('UTF-8') if string.respond_to?(:force_encoding) + assert_match(string, mail.subject.decoded) end def test_implicitly_multipart_with_utf8 mail = TestMailer.implicitly_multipart_with_utf8 - assert_match(/\nSubject: =\?utf-8\?Q\?Foo_.*?\?=/, mail.encoded) + regex = Regexp.escape('Subject: =?UTF-8?Q?Foo_=C3=A1=C3=AB=C3=B4_=C3=AE=C3=BC=?=') + assert_match(/#{regex}/, mail.encoded) + string.force_encoding('UTF-8') if string.respond_to?(:force_encoding) + assert_match(string, mail.subject.decoded) end def test_explicitly_multipart_messages @@ -909,11 +916,11 @@ EOF assert_equal "1.0", mail.mime_version.to_s 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 "UTF-8", mail.parts[0].charset assert_equal "text/html", mail.parts[1].mime_type - assert_equal "utf-8", mail.parts[1].charset + assert_equal "UTF-8", mail.parts[1].charset assert_equal "application/x-yaml", mail.parts[2].mime_type - assert_equal "utf-8", mail.parts[2].charset + assert_equal "UTF-8", mail.parts[2].charset end def test_implicitly_multipart_messages_with_custom_order @@ -1044,13 +1051,13 @@ EOF mail = FunkyPathMailer.multipart_with_template_path_with_dots(@recipient) assert_equal 2, mail.parts.length assert "text/plain", mail.parts[1].mime_type - assert "utf-8", mail.parts[1].charset + assert "UTF-8", mail.parts[1].charset end def test_custom_content_type_attributes mail = TestMailer.custom_content_type_attributes assert_match %r{format=flowed}, mail.content_type - assert_match %r{charset=utf-8}, mail.content_type + assert_match %r{charset=UTF-8}, mail.content_type end def test_return_path_with_create -- cgit v1.2.3