diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-10-04 17:08:25 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-10-04 17:08:25 -0700 |
commit | 8a9747021085c569f0118db1093bc12cfa2ba915 (patch) | |
tree | 8de97e3ed2a14c8af4e1ddfc1178272c1a6bfae3 /actionpack | |
parent | 876acf001a32887679e259f83a2fbad750ac2e67 (diff) | |
download | rails-8a9747021085c569f0118db1093bc12cfa2ba915.tar.gz rails-8a9747021085c569f0118db1093bc12cfa2ba915.tar.bz2 rails-8a9747021085c569f0118db1093bc12cfa2ba915.zip |
raising an argument error if tempfile is not provided
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/http/upload.rb | 1 | ||||
-rw-r--r-- | actionpack/test/dispatch/uploaded_file_test.rb | 12 |
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 |