diff options
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/test_test.rb | 27 | ||||
-rw-r--r-- | actionpack/test/fixtures/multipart/mona_lisa.jpg | bin | 0 -> 159528 bytes |
2 files changed, 27 insertions, 0 deletions
diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_test.rb index 25c514d5a3..06a2ce3eb7 100644 --- a/actionpack/test/controller/test_test.rb +++ b/actionpack/test/controller/test_test.rb @@ -49,6 +49,10 @@ HTML def test_remote_addr render :text => (request.remote_addr || "not specified") end + + def test_file_upload + render :text => params[:file].size + end def rescue_action(e) raise e @@ -366,4 +370,27 @@ HTML end end end + + FILES_DIR = File.dirname(__FILE__) + '/../fixtures/multipart' + + def test_test_uploaded_file + filename = 'mona_lisa.jpg' + path = "#{FILES_DIR}/#{filename}" + content_type = 'image/png' + + file = ActionController::TestUploadedFile.new(path, content_type) + assert_equal filename, file.original_filename + assert_equal content_type, file.content_type + assert_equal file.path, file.local_path + assert_equal File.read(path), file.read + end + + def test_fixture_file_upload + post :test_file_upload, :file => fixture_file_upload(FILES_DIR + "/mona_lisa.jpg", "image/jpg") + assert_equal 159528, @response.body + end + + def test_test_uploaded_file_exception_when_file_doesnt_exist + assert_raise(RuntimeError) { ActionController::TestUploadedFile.new('non_existent_file') } + end end diff --git a/actionpack/test/fixtures/multipart/mona_lisa.jpg b/actionpack/test/fixtures/multipart/mona_lisa.jpg Binary files differnew file mode 100644 index 0000000000..5cf3bef3d0 --- /dev/null +++ b/actionpack/test/fixtures/multipart/mona_lisa.jpg |