aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/test
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2008-04-03 17:28:05 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2008-04-03 17:28:05 +0000
commit5c17a74d59f9525744e30d64472e8b43e808ba6f (patch)
tree58ef741cfe97d5512b08b40feee259d2897a7006 /actionmailer/test
parentc9aaad795dbeaa9133a14b0d40fb0683cad30a2f (diff)
downloadrails-5c17a74d59f9525744e30d64472e8b43e808ba6f.tar.gz
rails-5c17a74d59f9525744e30d64472e8b43e808ba6f.tar.bz2
rails-5c17a74d59f9525744e30d64472e8b43e808ba6f.zip
Ruby 1.9 compat: compare with same encoding
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9218 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionmailer/test')
-rwxr-xr-xactionmailer/test/mail_service_test.rb6
-rw-r--r--actionmailer/test/quoting_test.rb23
2 files changed, 18 insertions, 11 deletions
diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb
index 901b03c05f..57a651ccd4 100755
--- a/actionmailer/test/mail_service_test.rb
+++ b/actionmailer/test/mail_service_test.rb
@@ -840,7 +840,11 @@ EOF
fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email8")
mail = TMail::Mail.parse(fixture)
attachment = mail.attachments.last
- assert_equal "01 Quien Te Dij\212at. Pitbull.mp3", attachment.original_filename
+
+ expected = "01 Quien Te Dij\212at. Pitbull.mp3"
+ expected.force_encoding(Encoding::ASCII_8BIT) if expected.respond_to?(:force_encoding)
+
+ assert_equal expected, attachment.original_filename
end
def test_wrong_mail_header
diff --git a/actionmailer/test/quoting_test.rb b/actionmailer/test/quoting_test.rb
index 7e300942cb..ca7282faac 100644
--- a/actionmailer/test/quoting_test.rb
+++ b/actionmailer/test/quoting_test.rb
@@ -73,18 +73,15 @@ class QuotingTest < Test::Unit::TestCase
assert_equal "Re: Test: \"\346\274\242\345\255\227\" mid \"\346\274\242\345\255\227\" tail", mail.subject
end
- def test_decode
- encoded, decoded = expected_base64_strings
- assert_equal decoded, TMail::Base64.decode(encoded)
- end
+ def test_base64_encoding
+ encoded = read_fixture('raw_base64_encoded_string')
+ decoded = read_fixture('raw_base64_decoded_string')
- def test_encode
- encoded, decoded = expected_base64_strings
- assert_equal encoded.length, TMail::Base64.encode(decoded).length
+ assert_equal encoded, TMail::Base64.encode(decoded)
+ assert_equal decoded, TMail::Base64.decode(encoded)
end
private
-
# This whole thing *could* be much simpler, but I don't think Tempfile,
# popen and others exist on all platforms (like Windows).
def execute_in_sandbox(code)
@@ -107,7 +104,13 @@ class QuotingTest < Test::Unit::TestCase
File.delete(res_name) rescue nil
end
- def expected_base64_strings
- [ File.read("#{File.dirname(__FILE__)}/fixtures/raw_base64_encoded_string"), File.read("#{File.dirname(__FILE__)}/fixtures/raw_base64_decoded_string") ]
+ if RUBY_VERSION >= '1.9'
+ def read_fixture(name)
+ File.open("#{File.dirname(__FILE__)}/fixtures/raw_base64_encoded_string", 'r:ascii-8bit') { |f| f.read }
+ end
+ else
+ def read_fixture(name)
+ File.read("#{File.dirname(__FILE__)}/fixtures/raw_base64_encoded_string")
+ end
end
end