diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-09-14 07:34:45 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-09-14 07:34:45 +0000 |
commit | c87206cc575031ae5d422a7729e32954e1184b26 (patch) | |
tree | 84d1427f749d7fdb4f69d105eda79cb5ce053ba4 /actionpack/test/controller/test_test.rb | |
parent | 498d8ff72eded86fb1064205332e0a91b1dacece (diff) | |
download | rails-c87206cc575031ae5d422a7729e32954e1184b26.tar.gz rails-c87206cc575031ae5d422a7729e32954e1184b26.tar.bz2 rails-c87206cc575031ae5d422a7729e32954e1184b26.zip |
Add option to force binary mode on tempfile used for fixture_file_upload. Closes #6380.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7478 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/controller/test_test.rb')
-rw-r--r-- | actionpack/test/controller/test_test.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_test.rb index 10818fe1c9..8a57f37b68 100644 --- a/actionpack/test/controller/test_test.rb +++ b/actionpack/test/controller/test_test.rb @@ -460,6 +460,30 @@ XML assert_equal file.path, file.local_path assert_equal File.read(path), file.read end + + def test_test_uploaded_file_with_binary + filename = 'mona_lisa.jpg' + path = "#{FILES_DIR}/#{filename}" + content_type = 'image/png' + + binary_uploaded_file = ActionController::TestUploadedFile.new(path, content_type, :binary) + assert_equal File.open(path, 'rb').read, binary_uploaded_file.read + + plain_uploaded_file = ActionController::TestUploadedFile.new(path, content_type) + assert_equal File.open(path, 'r').read, plain_uploaded_file.read + end + + def test_fixture_file_upload_with_binary + filename = 'mona_lisa.jpg' + path = "#{FILES_DIR}/#{filename}" + content_type = 'image/jpg' + + binary_file_upload = fixture_file_upload(path, content_type, :binary) + assert_equal File.open(path, 'rb').read, binary_file_upload.read + + plain_file_upload = fixture_file_upload(path, content_type) + assert_equal File.open(path, 'r').read, plain_file_upload.read + end def test_fixture_file_upload post :test_file_upload, :file => fixture_file_upload(FILES_DIR + "/mona_lisa.jpg", "image/jpg") |