aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergio Gil Pérez de la Manga <sgilperez@gmail.com>2012-09-22 22:37:00 +0200
committerSergio Gil Pérez de la Manga <sgilperez@gmail.com>2012-09-22 22:37:00 +0200
commite9ba548baf74cc3a5ec65135dac385d81e14f06e (patch)
tree0d6c38dd3d0b75e364398dfff8c9b1b41eb12893
parentf3afaa64cf13f15b2a6199d1be8fa4ce9f3fd612 (diff)
downloadrails-e9ba548baf74cc3a5ec65135dac385d81e14f06e.tar.gz
rails-e9ba548baf74cc3a5ec65135dac385d81e14f06e.tar.bz2
rails-e9ba548baf74cc3a5ec65135dac385d81e14f06e.zip
Accept parameters in methods delegated to tempfile
-rw-r--r--actionpack/lib/action_dispatch/http/upload.rb8
-rw-r--r--actionpack/test/dispatch/uploaded_file_test.rb6
2 files changed, 8 insertions, 6 deletions
diff --git a/actionpack/lib/action_dispatch/http/upload.rb b/actionpack/lib/action_dispatch/http/upload.rb
index 42da35edec..d50c8cad17 100644
--- a/actionpack/lib/action_dispatch/http/upload.rb
+++ b/actionpack/lib/action_dispatch/http/upload.rb
@@ -12,13 +12,9 @@ module ActionDispatch
@headers = hash[:head]
end
- def read(*args)
- @tempfile.read(*args)
- end
-
# Delegate these methods to the tempfile.
- [:open, :close, :path, :rewind, :size, :eof?].each do |method|
- class_eval "def #{method}; @tempfile.#{method}; end"
+ [:read, :open, :close, :path, :rewind, :size, :eof?].each do |method|
+ class_eval "def #{method}(*args); @tempfile.#{method}(*args); end"
end
private
diff --git a/actionpack/test/dispatch/uploaded_file_test.rb b/actionpack/test/dispatch/uploaded_file_test.rb
index c921a16a4f..f72afe745c 100644
--- a/actionpack/test/dispatch/uploaded_file_test.rb
+++ b/actionpack/test/dispatch/uploaded_file_test.rb
@@ -51,6 +51,12 @@ module ActionDispatch
assert_equal 'thunderhorse', uf.close
end
+ def test_close_accepts_parameter
+ tf = Class.new { def close(optional = false); "thunderhorse: #{optional}" end }
+ uf = Http::UploadedFile.new(:tempfile => tf.new)
+ assert_equal 'thunderhorse: true', uf.close(true)
+ end
+
def test_delegates_to_tempfile
tf = Class.new { def read; 'thunderhorse' end }
uf = Http::UploadedFile.new(:tempfile => tf.new)