Skip to content

Commit

Permalink
Ruby 1.9 compat: file uploads. References #1689 [Frederick Cheung]
Browse files Browse the repository at this point in the history
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8492 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
jeremy committed Dec 27, 2007
1 parent 699cc15 commit 41c82e6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions actionpack/lib/action_controller/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ def get_typed_value(value)
when Array
value.map { |v| get_typed_value(v) }
else
if value.is_a?(UploadedFile)
if value.respond_to? :original_filename
# Uploaded file
if value.original_filename
value
Expand All @@ -498,7 +498,7 @@ def get_typed_value(value)
def read_multipart(body, boundary, content_length, env)
params = Hash.new([])
boundary = "--" + boundary
quoted_boundary = Regexp.quote(boundary, "n")
quoted_boundary = Regexp.quote(boundary)
buf = ""
bufsize = 10 * 1024
boundary_end=""
Expand Down
2 changes: 1 addition & 1 deletion actionpack/test/controller/dispatcher_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def setup
end

def teardown
ENV['REQUEST_METHOD'] = nil
ENV.delete 'REQUEST_METHOD'
end

def test_clears_dependencies_after_dispatch_if_in_loading_mode
Expand Down
6 changes: 5 additions & 1 deletion actionpack/test/controller/request_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,11 @@ def test_large_text_file
assert_equal 'bar', params['foo']

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 "text/plain", file.content_type
assert ('a' * 20480) == file.read
Expand Down

0 comments on commit 41c82e6

Please sign in to comment.