aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/test_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test/controller/test_test.rb')
-rw-r--r--actionpack/test/controller/test_test.rb24
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")