Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #1689: file_upload_fixes.diff

File file_upload_fixes.diff, 1.9 kB (added by fcheung, 6 months ago)
  • actionpack/test/controller/dispatcher_test.rb

    old new  
    1616  end 
    1717 
    1818  def teardown 
    19     ENV['REQUEST_METHOD'] = nil 
     19    ENV.delete 'REQUEST_METHOD' 
    2020  end 
    2121 
    2222  def test_clears_dependencies_after_dispatch_if_in_loading_mode 
  • actionpack/test/controller/request_test.rb

    old new  
    731731    assert_equal 'bar', params['foo'] 
    732732 
    733733    file = params['file'] 
    734     assert_kind_of Tempfile, file 
     734    if RUBY_VERSION > '1.9' 
     735      assert_kind_of File, file 
     736    else 
     737      assert_kind_of Tempfile, file 
     738    end 
    735739    assert_equal 'file.txt', file.original_filename 
    736740    assert_equal "text/plain", file.content_type 
    737741    assert ('a' * 20480) == file.read 
  • actionpack/lib/action_controller/request.rb

    old new  
    473473            when Array 
    474474              value.map { |v| get_typed_value(v) } 
    475475            else 
    476               if value.is_a?(UploadedFile) 
     476              if value.respond_to? :original_filename 
    477477                # Uploaded file 
    478478                if value.original_filename 
    479479                  value 
     
    498498        def read_multipart(body, boundary, content_length, env) 
    499499          params = Hash.new([]) 
    500500          boundary = "--" + boundary 
    501           quoted_boundary = Regexp.quote(boundary, "n"
     501          quoted_boundary = Regexp.quote(boundary
    502502          buf = "" 
    503503          bufsize = 10 * 1024 
    504504          boundary_end=""