Skip to content

Commit

Permalink
delegating path and open to internal tempfile
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Nov 18, 2010
1 parent 2692375 commit c52e2cf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
10 changes: 8 additions & 2 deletions actionpack/lib/action_dispatch/http/upload.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'active_support/core_ext/object/blank'

module ActionDispatch
module Http
class UploadedFile
Expand All @@ -13,6 +11,14 @@ def initialize(hash)
raise(ArgumentError, ':tempfile is required') unless @tempfile
end

def open
@tempfile.open
end

def path
@tempfile.path
end

def read(*args)
@tempfile.read(*args)
end
Expand Down
12 changes: 12 additions & 0 deletions actionpack/test/dispatch/uploaded_file_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ def test_tempfile
assert_equal 'foo', uf.tempfile
end

def test_delegates_path_to_tempfile
tf = Class.new { def path; 'thunderhorse' end }
uf = Http::UploadedFile.new(:tempfile => tf.new)
assert_equal 'thunderhorse', uf.path
end

def test_delegates_open_to_tempfile
tf = Class.new { def open; 'thunderhorse' end }
uf = Http::UploadedFile.new(:tempfile => tf.new)
assert_equal 'thunderhorse', uf.open
end

def test_delegates_to_tempfile
tf = Class.new { def read; 'thunderhorse' end }
uf = Http::UploadedFile.new(:tempfile => tf.new)
Expand Down

1 comment on commit c52e2cf

@trevorturk
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick fix. This one really threw me for a loop when upgrading to 3.0.3.

Here's a workaround that'll be useful until a new release comes out: http://marklunds.com/articles/one/433

Please sign in to comment.