Permalink
Browse files

raising an argument error if tempfile is not provided

  • Loading branch information...
1 parent 003d67e commit d75244785fed2efe6283861fca2d6186d41d0263 @tenderlove tenderlove committed Oct 5, 2010
Showing with 10 additions and 3 deletions.
  1. +1 −0 actionpack/lib/action_dispatch/http/upload.rb
  2. +9 −3 actionpack/test/dispatch/uploaded_file_test.rb
@@ -10,6 +10,7 @@ def initialize(hash)
@content_type = hash[:type]
@headers = hash[:head]
@tempfile = hash[:tempfile]
+ raise(ArgumentError, ':tempfile is required') unless @tempfile
end
def method_missing(name, *args, &block)
@@ -2,18 +2,24 @@
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

0 comments on commit d752447

Please sign in to comment.