Permalink
Browse files

Since File instance doesn't respond to #open use a double to test the

behavior added at c53e5de
  • Loading branch information...
1 parent 19987b6 commit 628e38d789176bf53822942598547dee21d5ce70 @rafaelfranca rafaelfranca committed Oct 1, 2012
View
2 actionpack/lib/action_dispatch/http/upload.rb
@@ -19,7 +19,7 @@ def read(*args)
[:open, :path, :rewind, :size].each do |method|
class_eval "def #{method}; @tempfile.#{method}; end"
end
-
+
private
def encode_filename(filename)
# Encode the filename in the utf8 encoding, unless it is nil or we're in 1.8
View
5 actionpack/test/controller/test_test.rb
@@ -767,9 +767,8 @@ def test_fixture_file_upload
end
def test_action_dispatch_uploaded_file_upload
- filename = 'mona_lisa.jpg'
- path = "#{FILES_DIR}/#{filename}"
- post :test_file_upload, :file => ActionDispatch::Http::UploadedFile.new(:filename => path, :type => "image/jpg", :tempfile => File.open(path))
+ tf = Class.new { def size; 159528 end }
+ post :test_file_upload, :file => ActionDispatch::Http::UploadedFile.new(:tempfile => tf.new)
assert_equal '159528', @response.body
end
View
2 actionpack/test/dispatch/uploaded_file_test.rb
@@ -12,7 +12,7 @@ def test_original_filename
uf = Http::UploadedFile.new(:filename => 'foo', :tempfile => Object.new)
assert_equal 'foo', uf.original_filename
end
-
+
if "ruby".encoding_aware?
def test_filename_should_be_in_utf_8
uf = Http::UploadedFile.new(:filename => 'foo', :tempfile => Object.new)

0 comments on commit 628e38d

Please sign in to comment.