mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Ruby 1.9 compat: file uploads. References #1689 [Frederick Cheung]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8492 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
699cc15116
commit
41c82e66c1
3 changed files with 8 additions and 4 deletions
|
@ -473,7 +473,7 @@ module ActionController
|
||||||
when Array
|
when Array
|
||||||
value.map { |v| get_typed_value(v) }
|
value.map { |v| get_typed_value(v) }
|
||||||
else
|
else
|
||||||
if value.is_a?(UploadedFile)
|
if value.respond_to? :original_filename
|
||||||
# Uploaded file
|
# Uploaded file
|
||||||
if value.original_filename
|
if value.original_filename
|
||||||
value
|
value
|
||||||
|
@ -498,7 +498,7 @@ module ActionController
|
||||||
def read_multipart(body, boundary, content_length, env)
|
def read_multipart(body, boundary, content_length, env)
|
||||||
params = Hash.new([])
|
params = Hash.new([])
|
||||||
boundary = "--" + boundary
|
boundary = "--" + boundary
|
||||||
quoted_boundary = Regexp.quote(boundary, "n")
|
quoted_boundary = Regexp.quote(boundary)
|
||||||
buf = ""
|
buf = ""
|
||||||
bufsize = 10 * 1024
|
bufsize = 10 * 1024
|
||||||
boundary_end=""
|
boundary_end=""
|
||||||
|
|
|
@ -16,7 +16,7 @@ class DispatcherTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def teardown
|
def teardown
|
||||||
ENV['REQUEST_METHOD'] = nil
|
ENV.delete 'REQUEST_METHOD'
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_clears_dependencies_after_dispatch_if_in_loading_mode
|
def test_clears_dependencies_after_dispatch_if_in_loading_mode
|
||||||
|
|
|
@ -731,7 +731,11 @@ class MultipartRequestParameterParsingTest < Test::Unit::TestCase
|
||||||
assert_equal 'bar', params['foo']
|
assert_equal 'bar', params['foo']
|
||||||
|
|
||||||
file = params['file']
|
file = params['file']
|
||||||
assert_kind_of Tempfile, file
|
if RUBY_VERSION > '1.9'
|
||||||
|
assert_kind_of File, file
|
||||||
|
else
|
||||||
|
assert_kind_of Tempfile, file
|
||||||
|
end
|
||||||
assert_equal 'file.txt', file.original_filename
|
assert_equal 'file.txt', file.original_filename
|
||||||
assert_equal "text/plain", file.content_type
|
assert_equal "text/plain", file.content_type
|
||||||
assert ('a' * 20480) == file.read
|
assert ('a' * 20480) == file.read
|
||||||
|
|
Loading…
Reference in a new issue