diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-11-18 10:10:18 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-11-18 10:10:25 -0800 |
commit | c52e2cf4b3ef22fea6989df906a53188e632b9a4 (patch) | |
tree | a360f8418b53e3963e38bfce209e488dd95c208b /actionpack | |
parent | 26923756fb23eb9c2993a365f9819027f20d5e77 (diff) | |
download | rails-c52e2cf4b3ef22fea6989df906a53188e632b9a4.tar.gz rails-c52e2cf4b3ef22fea6989df906a53188e632b9a4.tar.bz2 rails-c52e2cf4b3ef22fea6989df906a53188e632b9a4.zip |
delegating path and open to internal tempfile
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/http/upload.rb | 10 | ||||
-rw-r--r-- | actionpack/test/dispatch/uploaded_file_test.rb | 12 |
2 files changed, 20 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/http/upload.rb b/actionpack/lib/action_dispatch/http/upload.rb index 84e58d7d6a..37effade4f 100644 --- a/actionpack/lib/action_dispatch/http/upload.rb +++ b/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 @@ module ActionDispatch 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 diff --git a/actionpack/test/dispatch/uploaded_file_test.rb b/actionpack/test/dispatch/uploaded_file_test.rb index b51697b930..e2a7f1bad7 100644 --- a/actionpack/test/dispatch/uploaded_file_test.rb +++ b/actionpack/test/dispatch/uploaded_file_test.rb @@ -28,6 +28,18 @@ module ActionDispatch 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) |