From 48d33664cb4afeec2623f75848375610545dbafd Mon Sep 17 00:00:00 2001 From: dpickett Date: Tue, 20 Apr 2010 21:24:13 -0400 Subject: [PATCH] verify multipart doesn't break param encoding [#2439] in Rails 2.3.x Steven Luscher observed this was broken. This patch validates the errant behavior was not present in Rails 3 --- actionpack/test/controller/integration_test.rb | 33 ++++++++++++++++++++++++ 1 files changed, 33 insertions(+), 0 deletions(-) diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb index 20dc96d..9d4741d 100644 --- a/actionpack/test/controller/integration_test.rb +++ b/actionpack/test/controller/integration_test.rb @@ -230,6 +230,14 @@ class IntegrationProcessTest < ActionController::IntegrationTest def get_with_params render :text => "foo: #{params[:foo]}", :status => 200 end + + def post_with_multiparameter_params + render :text => "foo(1i): #{params[:"foo(1i)"]}, foo(2i): #{params[:"foo(2i)"]}", :status => 200 + end + + def multipart_post_with_multiparameter_params + render :text => "foo(1i): #{params[:"foo(1i)"]}, foo(2i): #{params[:"foo(2i)"]}, filesize: #{params[:file].size}", :status => 200 + end def post render :text => "Created", :status => 201 @@ -291,6 +299,31 @@ class IntegrationProcessTest < ActionController::IntegrationTest end end + FILES_DIR = File.dirname(__FILE__) + '/../fixtures/multipart' + + def test_post_with_multiparameter_attribute_parameters + with_test_route_set do + post '/post_with_multiparameter_params', + :"foo(1i)" => "bar", + :"foo(2i)" => "baz" + + assert_equal 200, status + assert_equal "foo(1i): bar, foo(2i): baz", response.body + end + end + + def test_multipart_post_with_multiparameter_attribute_parameters + with_test_route_set do + post '/multipart_post_with_multiparameter_params', + :"foo(1i)" => "bar", + :"foo(2i)" => "baz", + :file => fixture_file_upload(FILES_DIR + "/mona_lisa.jpg", "image/jpg") + + assert_equal 200, status + assert_equal "foo(1i): bar, foo(2i): baz, filesize: 159528", response.body + end + end + test 'response cookies are added to the cookie jar for the next request' do with_test_route_set do self.cookies['cookie_1'] = "sugar" -- 1.6.6