mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Accept parameters in methods delegated to tempfile
This commit is contained in:
parent
f3afaa64cf
commit
e9ba548baf
2 changed files with 8 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue