aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/test/base_test.rb
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2010-03-31 07:47:58 -0700
committerXavier Noria <fxn@hashref.com>2010-03-31 07:47:58 -0700
commit824fa10f4d1306cc1e310a7d5de7e95cfb07d6f8 (patch)
tree1967c2a945d6e131d467fb4f0178a0f60e01ae8a /actionmailer/test/base_test.rb
parent1ed1652bef981d9402797b6cb9f0920a40eea21a (diff)
parentdb28d407f76a790a31e27bf51560e23425dd6944 (diff)
downloadrails-824fa10f4d1306cc1e310a7d5de7e95cfb07d6f8.tar.gz
rails-824fa10f4d1306cc1e310a7d5de7e95cfb07d6f8.tar.bz2
rails-824fa10f4d1306cc1e310a7d5de7e95cfb07d6f8.zip
Merge commit 'rails/master'
Diffstat (limited to 'actionmailer/test/base_test.rb')
-rw-r--r--actionmailer/test/base_test.rb34
1 files changed, 25 insertions, 9 deletions
diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb
index 6f274c11df..baeee542be 100644
--- a/actionmailer/test/base_test.rb
+++ b/actionmailer/test/base_test.rb
@@ -39,8 +39,15 @@ class BaseTest < ActiveSupport::TestCase
end
def attachment_with_hash
- attachments['invoice.jpg'] = { :data => "you smiling", :mime_type => "image/x-jpg",
- :transfer_encoding => "base64" }
+ attachments['invoice.jpg'] = { :data => "\312\213\254\232)b",
+ :mime_type => "image/x-jpg",
+ :transfer_encoding => "base64" }
+ mail
+ end
+
+ def attachment_with_hash_default_encoding
+ attachments['invoice.jpg'] = { :data => "\312\213\254\232)b",
+ :mime_type => "image/x-jpg" }
mail
end
@@ -135,13 +142,13 @@ class BaseTest < ActiveSupport::TestCase
:mime_version => '2.0',
:reply_to => 'reply-to@test.lindsaar.net',
:date => @time)
- assert_equal(['bcc@test.lindsaar.net'], email.bcc)
- assert_equal(['cc@test.lindsaar.net'], email.cc)
- assert_equal('multipart/mixed', email.content_type)
- assert_equal('iso-8559-1', email.charset)
- assert_equal('2.0', email.mime_version)
- assert_equal(['reply-to@test.lindsaar.net'], email.reply_to)
- assert_equal(@time, email.date)
+ assert_equal(['bcc@test.lindsaar.net'], email.bcc)
+ assert_equal(['cc@test.lindsaar.net'], email.cc)
+ assert_equal('multipart/mixed; charset=iso-8559-1', email.content_type)
+ assert_equal('iso-8559-1', email.charset)
+ assert_equal('2.0', email.mime_version)
+ assert_equal(['reply-to@test.lindsaar.net'], email.reply_to)
+ assert_equal(@time, email.date)
end
test "mail() renders the template using the method being processed" do
@@ -206,6 +213,15 @@ class BaseTest < ActiveSupport::TestCase
assert_equal expected, email.attachments['invoice.jpg'].decoded
end
+ test "attachment with hash using default mail encoding" do
+ email = BaseMailer.attachment_with_hash_default_encoding
+ assert_equal(1, email.attachments.length)
+ assert_equal('invoice.jpg', email.attachments[0].filename)
+ expected = "\312\213\254\232)b"
+ expected.force_encoding(Encoding::BINARY) if '1.9'.respond_to?(:force_encoding)
+ assert_equal expected, email.attachments['invoice.jpg'].decoded
+ end
+
test "sets mime type to multipart/mixed when attachment is included" do
email = BaseMailer.attachment_with_content
assert_equal(1, email.attachments.length)