Permalink
Browse files

Accept parameters in methods delegated to tempfile

  • Loading branch information...
1 parent f3afaa6 commit e9ba548baf74cc3a5ec65135dac385d81e14f06e @porras porras committed Sep 22, 2012
Showing with 8 additions and 6 deletions.
  1. +2 −6 actionpack/lib/action_dispatch/http/upload.rb
  2. +6 −0 actionpack/test/dispatch/uploaded_file_test.rb
@@ -12,13 +12,9 @@ def initialize(hash)
@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
@@ -51,6 +51,12 @@ def test_delegates_close_to_tempfile
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)

0 comments on commit e9ba548

Please sign in to comment.