提交 c52e2cf4 编写于 作者: A Aaron Patterson

delegating path and open to internal tempfile

上级 26923756
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
......
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册