diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2018-06-11 09:32:27 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-11 09:32:27 +0900 |
commit | 4eb1481c7f66a5c378b218676ece43b8ae13e553 (patch) | |
tree | c672a827ac578099e8d904dd75f499621decc92a | |
parent | a81d47aa413bb31b06b1b8b22411a49a2b119a0e (diff) | |
parent | e4e1b62007fe40c4277ebc30067837a91bf25967 (diff) | |
download | rails-4eb1481c7f66a5c378b218676ece43b8ae13e553.tar.gz rails-4eb1481c7f66a5c378b218676ece43b8ae13e553.tar.bz2 rails-4eb1481c7f66a5c378b218676ece43b8ae13e553.zip |
Merge pull request #33093 from rails/use-rack-to-dump-query
Use Rack to generate query information under test
-rw-r--r-- | actionpack/lib/action_controller/test_case.rb | 2 | ||||
-rw-r--r-- | actionpack/test/controller/test_case_test.rb | 12 |
2 files changed, 11 insertions, 3 deletions
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index 5d784ceb31..33b0bcbefe 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 = non_path_parameters.to_query + data = Rack::Utils.build_nested_query(non_path_parameters) else @custom_param_parsers[content_mime_type.symbol] = ->(_) { non_path_parameters } data = non_path_parameters.to_query diff --git a/actionpack/test/controller/test_case_test.rb b/actionpack/test/controller/test_case_test.rb index 734da3de9c..d4620d085a 100644 --- a/actionpack/test/controller/test_case_test.rb +++ b/actionpack/test/controller/test_case_test.rb @@ -220,7 +220,15 @@ XML params = Hash[:page, { name: "page name" }, "some key", 123] post :render_raw_post, params: params.dup - assert_equal params.to_query, @response.body + assert_equal Rack::Utils.build_nested_query(params), @response.body + end + + def test_params_round_trip + params = {"foo"=>{"contents"=>[{"name"=>"gorby", "id"=>"123"}, {"name"=>"puff", "d"=>"true"}]}} + post :test_params, params: params.dup + + controller_info = { "controller" => "test_case_test/test", "action" => "test_params" } + assert_equal params.merge(controller_info), JSON.parse(@response.body) end def test_body_stream @@ -228,7 +236,7 @@ XML post :render_body, params: params.dup - assert_equal params.to_query, @response.body + assert_equal Rack::Utils.build_nested_query(params), @response.body end def test_document_body_and_params_with_post |