Skip to content
Browse files

Delegate ActionDispatch::Http::UploadedFile#close to tempfile

  • Loading branch information...
1 parent 2068d30 commit dab08597417d55a1e9819781427aa2097ecdf2fb @porras porras committed
View
2 actionpack/lib/action_dispatch/http/upload.rb
@@ -17,7 +17,7 @@ def read(*args)
end
# Delegate these methods to the tempfile.
- [:open, :path, :rewind, :size, :eof?].each do |method|
+ [:open, :close, :path, :rewind, :size, :eof?].each do |method|
class_eval "def #{method}; @tempfile.#{method}; end"
end
View
6 actionpack/test/dispatch/uploaded_file_test.rb
@@ -45,6 +45,12 @@ def test_delegates_open_to_tempfile
assert_equal 'thunderhorse', uf.open
end
+ def test_delegates_close_to_tempfile
+ tf = Class.new { def close; 'thunderhorse' end }
+ uf = Http::UploadedFile.new(:tempfile => tf.new)
+ assert_equal 'thunderhorse', uf.close
+ end
+
def test_delegates_to_tempfile
tf = Class.new { def read; 'thunderhorse' end }
uf = Http::UploadedFile.new(:tempfile => tf.new)

0 comments on commit dab0859

Please sign in to comment.
Something went wrong with that request. Please try again.