diff options
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/request/multipart_params_parsing_test.rb | 12 | ||||
-rw-r--r-- | actionpack/test/fixtures/multipart/empty | 3 | ||||
-rw-r--r-- | actionpack/test/fixtures/multipart/none | 9 |
3 files changed, 21 insertions, 3 deletions
diff --git a/actionpack/test/controller/request/multipart_params_parsing_test.rb b/actionpack/test/controller/request/multipart_params_parsing_test.rb index 18235845f3..054519d0d2 100644 --- a/actionpack/test/controller/request/multipart_params_parsing_test.rb +++ b/actionpack/test/controller/request/multipart_params_parsing_test.rb @@ -101,11 +101,19 @@ class MultipartParamsParsingTest < ActionController::IntegrationTest assert_equal 19756, files.size end - test "skips empty upload field" do + test "does not create tempfile if no file has been selected" do + params = parse_multipart('none') + assert_equal %w(files submit-name), params.keys.sort + assert_equal 'Larry', params['submit-name'] + assert_equal nil, params['files'] + end + + test "parses empty upload file" do params = parse_multipart('empty') assert_equal %w(files submit-name), params.keys.sort assert_equal 'Larry', params['submit-name'] - assert_equal nil, params['file'] + assert params['files'] + assert_equal "", params['files'].read end test "uploads and reads binary file" do diff --git a/actionpack/test/fixtures/multipart/empty b/actionpack/test/fixtures/multipart/empty index d66f4730f1..f0f79835c9 100644 --- a/actionpack/test/fixtures/multipart/empty +++ b/actionpack/test/fixtures/multipart/empty @@ -3,7 +3,8 @@ Content-Disposition: form-data; name="submit-name" Larry
--AaB03x
-Content-Disposition: form-data; name="files"; filename=""
+Content-Disposition: form-data; name="files"; filename="file1.txt"
+Content-Type: text/plain
--AaB03x--
diff --git a/actionpack/test/fixtures/multipart/none b/actionpack/test/fixtures/multipart/none new file mode 100644 index 0000000000..d66f4730f1 --- /dev/null +++ b/actionpack/test/fixtures/multipart/none @@ -0,0 +1,9 @@ +--AaB03x
+Content-Disposition: form-data; name="submit-name"
+
+Larry
+--AaB03x
+Content-Disposition: form-data; name="files"; filename=""
+
+
+--AaB03x--
|