blob: b51697b9307d9adc327f0fa53cf72371239f2ca4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
require 'abstract_unit'
module ActionDispatch
class UploadedFileTest < ActiveSupport::TestCase
def test_constructor_with_argument_error
assert_raises(ArgumentError) do
Http::UploadedFile.new({})
end
end
def test_original_filename
uf = Http::UploadedFile.new(:filename => 'foo', :tempfile => Object.new)
assert_equal 'foo', uf.original_filename
end
def test_content_type
uf = Http::UploadedFile.new(:type => 'foo', :tempfile => Object.new)
assert_equal 'foo', uf.content_type
end
def test_headers
uf = Http::UploadedFile.new(:head => 'foo', :tempfile => Object.new)
assert_equal 'foo', uf.headers
end
def test_tempfile
uf = Http::UploadedFile.new(:tempfile => 'foo')
assert_equal 'foo', uf.tempfile
end
def test_delegates_to_tempfile
tf = Class.new { def read; 'thunderhorse' end }
uf = Http::UploadedFile.new(:tempfile => tf.new)
assert_equal 'thunderhorse', uf.read
end
def test_delegates_to_tempfile_with_params
tf = Class.new { def read *args; args end }
uf = Http::UploadedFile.new(:tempfile => tf.new)
assert_equal %w{ thunder horse }, uf.read(*%w{ thunder horse })
end
def test_delegate_respects_respond_to?
tf = Class.new { def read; yield end; private :read }
uf = Http::UploadedFile.new(:tempfile => tf.new)
assert_raises(NoMethodError) do
uf.read
end
end
def test_respond_to?
tf = Class.new { def read; yield end }
uf = Http::UploadedFile.new(:tempfile => tf.new)
assert uf.respond_to?(:headers), 'responds to headers'
assert uf.respond_to?(:read), 'responds to read'
end
end
end
|