aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/test
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-04-11 10:29:15 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-04-11 10:29:15 +0000
commit256e800a0125cdd724bb7bdefc091f36b872896f (patch)
treed8fc56ecfece464b045f00bc88da0b93b0bab0ff /actionmailer/test
parentea803aa4e3088522855d3695166b6489a273382f (diff)
downloadrails-256e800a0125cdd724bb7bdefc091f36b872896f.tar.gz
rails-256e800a0125cdd724bb7bdefc091f36b872896f.tar.bz2
rails-256e800a0125cdd724bb7bdefc091f36b872896f.zip
Fixed quoting for all address headers, not just to #955 [Jamis Buck] Added that quoting to UTF-8 only happens if the characters used are in that range #955 [Jamis Buck]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1142 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionmailer/test')
-rwxr-xr-xactionmailer/test/mail_service_test.rb50
1 files changed, 44 insertions, 6 deletions
diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb
index 262ce988a2..31169d576a 100755
--- a/actionmailer/test/mail_service_test.rb
+++ b/actionmailer/test/mail_service_test.rb
@@ -33,7 +33,7 @@ class TestMailer < ActionMailer::Base
def iso_charset(recipient)
@recipients = recipient
- @subject = "testing iso charsets"
+ @subject = "testing isø charsets"
@from = "system@loudthinking.com"
@sent_on = Time.local 2004, 12, 12
@cc = "nobody@loudthinking.com"
@@ -50,7 +50,17 @@ class TestMailer < ActionMailer::Base
@cc = "nobody@loudthinking.com"
@bcc = "root@loudthinking.com"
@body = "Nothing to see here."
- @encode_subject = false
+ end
+
+ def extended_headers(recipient)
+ @recipients = recipient
+ @subject = "testing extended headers"
+ @from = "Grytøyr <stian1@example.net>"
+ @sent_on = Time.local 2004, 12, 12
+ @cc = "Grytøyr <stian2@example.net>"
+ @bcc = "Grytøyr <stian3@example.net>"
+ @body = "Nothing to see here."
+ @charset = "iso-8859-1"
end
end
@@ -82,7 +92,7 @@ class ActionMailerTest < Test::Unit::TestCase
def test_signed_up
expected = new_mail
expected.to = @recipient
- expected.subject = encode "[Signed up] Welcome #{@recipient}"
+ expected.subject = "[Signed up] Welcome #{@recipient}"
expected.body = "Hello there, \n\nMr. #{@recipient}"
expected.from = "system@loudthinking.com"
expected.date = Time.local(2004, 12, 12)
@@ -100,7 +110,7 @@ class ActionMailerTest < Test::Unit::TestCase
def test_cancelled_account
expected = new_mail
expected.to = @recipient
- expected.subject = encode "[Cancelled] Goodbye #{@recipient}"
+ expected.subject = "[Cancelled] Goodbye #{@recipient}"
expected.body = "Goodbye, Mr. #{@recipient}"
expected.from = "system@loudthinking.com"
expected.date = Time.local(2004, 12, 12)
@@ -118,7 +128,7 @@ class ActionMailerTest < Test::Unit::TestCase
def test_cc_bcc
expected = new_mail
expected.to = @recipient
- expected.subject = encode "testing bcc/cc"
+ expected.subject = "testing bcc/cc"
expected.body = "Nothing to see here."
expected.from = "system@loudthinking.com"
expected.cc = "nobody@loudthinking.com"
@@ -143,7 +153,7 @@ class ActionMailerTest < Test::Unit::TestCase
def test_iso_charset
expected = new_mail( "iso-8859-1" )
expected.to = @recipient
- expected.subject = encode "testing iso charsets", "iso-8859-1"
+ expected.subject = encode "testing isø charsets", "iso-8859-1"
expected.body = "Nothing to see here."
expected.from = "system@loudthinking.com"
expected.cc = "nobody@loudthinking.com"
@@ -228,5 +238,33 @@ EOF
assert_equal "This_is_a_test\n2 + 2 =3D 4\n", mail.quoted_body
end
+ def test_extended_headers
+ @recipient = "Grytøyr <test@localhost>"
+
+ expected = new_mail "iso-8859-1"
+ expected.to = TestMailer.quote_address_if_necessary @recipient, "iso-8859-1"
+ expected.subject = "testing extended headers"
+ expected.body = "Nothing to see here."
+ expected.from = TestMailer.quote_address_if_necessary "Grytøyr <stian1@example.net>", "iso-8859-1"
+ expected.cc = TestMailer.quote_address_if_necessary "Grytøyr <stian2@example.net>", "iso-8859-1"
+ expected.bcc = TestMailer.quote_address_if_necessary "Grytøyr <stian3@example.net>", "iso-8859-1"
+ expected.date = Time.local 2004, 12, 12
+
+ created = nil
+ assert_nothing_raised do
+ created = TestMailer.create_extended_headers @recipient
+ end
+
+ assert_not_nil created
+ 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
+ end
+
end