Skip to content

Commit

Permalink
adds delegetion for eof? to AD::Http::UploadedFile
Browse files Browse the repository at this point in the history
if you want to read the file you may need to ask if there is something
to read from
  • Loading branch information
jigfox authored and drogus committed Mar 27, 2012
1 parent e96d04a commit 96b72ef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion actionpack/lib/action_dispatch/http/upload.rb
Expand Up @@ -17,7 +17,7 @@ def read(*args)
end

# Delegate these methods to the tempfile.
[:open, :path, :rewind, :size].each do |method|
[:open, :path, :rewind, :size, :eof?].each do |method|
class_eval "def #{method}; @tempfile.#{method}; end"
end

Expand Down
6 changes: 6 additions & 0 deletions actionpack/test/dispatch/uploaded_file_test.rb
Expand Up @@ -65,6 +65,12 @@ def test_delegate_respects_respond_to?
end
end

def test_delegate_eof_to_tempfile
tf = Class.new { def eof?; true end; }
uf = Http::UploadedFile.new(:tempfile => tf.new)
assert uf.eof?
end

def test_respond_to?
tf = Class.new { def read; yield end }
uf = Http::UploadedFile.new(:tempfile => tf.new)
Expand Down

0 comments on commit 96b72ef

Please sign in to comment.