aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller
diff options
context:
space:
mode:
authorEdouard CHIN <edouard.chin@shopify.com>2018-07-10 22:34:02 -0400
committerEdouard CHIN <edouard.chin@shopify.com>2018-07-12 13:04:27 -0400
commit48b6bacbc534d4be3fa89bc19ea83c357a20e598 (patch)
tree6c3a8bb3abd570eebfd8733ec4600093a5120404 /actionpack/lib/action_controller
parentd4ea114bd611c608482375af94f49e2d54889202 (diff)
downloadrails-48b6bacbc534d4be3fa89bc19ea83c357a20e598.tar.gz
rails-48b6bacbc534d4be3fa89bc19ea83c357a20e598.tar.bz2
rails-48b6bacbc534d4be3fa89bc19ea83c357a20e598.zip
e4e1b62 broke `to_param` handling:
- There was an issue inside controller tests where order params were not respected, the reason was because we were calling `Hash#to_query` which sorts the results lexicographically. 1e4e1b62 fixed that issue by not using `to_query` but instead a utility function provided by rack. - However with the fix came another issue where it's now no longer possible to do this ``` post :foo, params: { user: User.first } # Prior to the patch the controller will receive { "user" => "1" } # Whereas now you get { "user": "#<User: ...>" } ``` The fix in this PR is to modify `Hash#to_query` to sort only when it doesn't contain an array structure that looks something like "bar[]" Ref https://github.com/rails/rails/pull/33341#issuecomment-404039396
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r--actionpack/lib/action_controller/test_case.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb
index 33b0bcbefe..5d784ceb31 100644
--- a/actionpack/lib/action_controller/test_case.rb
+++ b/actionpack/lib/action_controller/test_case.rb
@@ -109,7 +109,7 @@ module ActionController
when :xml
data = non_path_parameters.to_xml
when :url_encoded_form
- data = Rack::Utils.build_nested_query(non_path_parameters)
+ data = non_path_parameters.to_query
else
@custom_param_parsers[content_mime_type.symbol] = ->(_) { non_path_parameters }
data = non_path_parameters.to_query