Skip to content
Browse files

delegating path and open to internal tempfile

  • Loading branch information...
1 parent 2692375 commit c52e2cf4b3ef22fea6989df906a53188e632b9a4 @tenderlove tenderlove committed Nov 18, 2010
Showing with 20 additions and 2 deletions.
  1. +8 −2 actionpack/lib/action_dispatch/http/upload.rb
  2. +12 −0 actionpack/test/dispatch/uploaded_file_test.rb
View
10 actionpack/lib/action_dispatch/http/upload.rb
@@ -1,5 +1,3 @@
-require 'active_support/core_ext/object/blank'
-
module ActionDispatch
module Http
class UploadedFile
@@ -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
View
12 actionpack/test/dispatch/uploaded_file_test.rb
@@ -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)

1 comment on commit c52e2cf

@trevorturk

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.
Something went wrong with that request. Please try again.