aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/lib/action_dispatch/http/upload.rb1
-rw-r--r--actionpack/test/dispatch/uploaded_file_test.rb12
2 files changed, 10 insertions, 3 deletions
diff --git a/actionpack/lib/action_dispatch/http/upload.rb b/actionpack/lib/action_dispatch/http/upload.rb
index bfbe7c5305..d4fabe1eaf 100644
--- a/actionpack/lib/action_dispatch/http/upload.rb
+++ b/actionpack/lib/action_dispatch/http/upload.rb
@@ -10,6 +10,7 @@ module ActionDispatch
@content_type = hash[:type]
@headers = hash[:head]
@tempfile = hash[:tempfile]
+ raise(ArgumentError, ':tempfile is required') unless @tempfile
end
def method_missing(name, *args, &block)
diff --git a/actionpack/test/dispatch/uploaded_file_test.rb b/actionpack/test/dispatch/uploaded_file_test.rb
index d04d5a8650..4173ce0a44 100644
--- a/actionpack/test/dispatch/uploaded_file_test.rb
+++ b/actionpack/test/dispatch/uploaded_file_test.rb
@@ -2,18 +2,24 @@ require 'abstract_unit'
module ActionDispatch
class UploadedFileTest < ActiveSupport::TestCase
+ def test_constructor_with_argument_error
+ assert_raises(ArgumentError) do
+ Http::UploadedFile.new({})
+ end
+ end
+
def test_original_filename
- uf = Http::UploadedFile.new(:filename => 'foo')
+ uf = Http::UploadedFile.new(:filename => 'foo', :tempfile => Object.new)
assert_equal 'foo', uf.original_filename
end
def test_content_type
- uf = Http::UploadedFile.new(:type => 'foo')
+ uf = Http::UploadedFile.new(:type => 'foo', :tempfile => Object.new)
assert_equal 'foo', uf.content_type
end
def test_headers
- uf = Http::UploadedFile.new(:head => 'foo')
+ uf = Http::UploadedFile.new(:head => 'foo', :tempfile => Object.new)
assert_equal 'foo', uf.headers
end