aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer
diff options
context:
space:
mode:
authorMikel Lindsaar <raasdnil@gmail.com>2010-03-28 17:03:33 +1100
committerMikel Lindsaar <raasdnil@gmail.com>2010-03-28 17:03:33 +1100
commit4e0d1cfad74454e65f6be5c265e0e4b4e099cec3 (patch)
treebcf69bc7d3a029ce83108e98f0cc95565895da27 /actionmailer
parentb91c57d16cc1b7b686e5ecc208dfe08648360803 (diff)
downloadrails-4e0d1cfad74454e65f6be5c265e0e4b4e099cec3.tar.gz
rails-4e0d1cfad74454e65f6be5c265e0e4b4e099cec3.tar.bz2
rails-4e0d1cfad74454e65f6be5c265e0e4b4e099cec3.zip
Fixing up attachment encoding specs to work with latest mail - and be correct
Diffstat (limited to 'actionmailer')
-rw-r--r--actionmailer/test/base_test.rb20
1 files changed, 18 insertions, 2 deletions
diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb
index aa28c5aa8b..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
@@ -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)