aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergio Gil Pérez de la Manga <sgilperez@gmail.com>2012-09-20 11:57:38 +0200
committerSergio Gil Pérez de la Manga <sgilperez@gmail.com>2012-09-20 11:57:38 +0200
commitdab08597417d55a1e9819781427aa2097ecdf2fb (patch)
treef613a05592d77d63a0cf8c81e695e79dfa0785fb
parent2068d300917ed95a82e7377ee77b397fc4084a61 (diff)
downloadrails-dab08597417d55a1e9819781427aa2097ecdf2fb.tar.gz
rails-dab08597417d55a1e9819781427aa2097ecdf2fb.tar.bz2
rails-dab08597417d55a1e9819781427aa2097ecdf2fb.zip
Delegate ActionDispatch::Http::UploadedFile#close to tempfile
-rw-r--r--actionpack/lib/action_dispatch/http/upload.rb2
-rw-r--r--actionpack/test/dispatch/uploaded_file_test.rb6
2 files changed, 7 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/http/upload.rb b/actionpack/lib/action_dispatch/http/upload.rb
index ce8c2729e9..42da35edec 100644
--- a/actionpack/lib/action_dispatch/http/upload.rb
+++ b/actionpack/lib/action_dispatch/http/upload.rb
@@ -17,7 +17,7 @@ module ActionDispatch
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
diff --git a/actionpack/test/dispatch/uploaded_file_test.rb b/actionpack/test/dispatch/uploaded_file_test.rb
index e69c1fbed4..c921a16a4f 100644
--- a/actionpack/test/dispatch/uploaded_file_test.rb
+++ b/actionpack/test/dispatch/uploaded_file_test.rb
@@ -45,6 +45,12 @@ module ActionDispatch
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)