diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2015-07-09 10:12:19 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2015-07-09 10:12:19 -0700 |
commit | 394b7be0368cdf992b29c40bf7f501418d630b64 (patch) | |
tree | 31c1f35680c11e08ae313f37afcc889e174803f0 /actionpack | |
parent | 40ed4eefe40d7ffd0ab35592cf6792dc05a7eae8 (diff) | |
download | rails-394b7be0368cdf992b29c40bf7f501418d630b64.tar.gz rails-394b7be0368cdf992b29c40bf7f501418d630b64.tar.bz2 rails-394b7be0368cdf992b29c40bf7f501418d630b64.zip |
set parameters as a query string
We should convert request parameters to a query string, then let the
request object parse that query string. This should give us results
that are more similar to the real-world
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_controller/test_case.rb | 15 | ||||
-rw-r--r-- | actionpack/test/controller/test_case_test.rb | 2 |
2 files changed, 10 insertions, 7 deletions
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index aec21eb35e..329e321888 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -34,8 +34,8 @@ module ActionController self.session_options = TestSession::DEFAULT_OPTIONS end - def query_parameters=(params) - @env["action_dispatch.request.query_parameters"] = params + def query_string=(string) + @env[Rack::QUERY_STRING] = string end def request_parameters=(params) @@ -70,8 +70,11 @@ module ActionController end if get? - self.query_parameters = non_path_parameters + if self.query_string.blank? + self.query_string = non_path_parameters.to_query + end else + @env['action_dispatch.request.query_parameters'] = {} self.request_parameters = non_path_parameters end @@ -506,6 +509,7 @@ module ActionController @request.env.delete 'HTTP_X_REQUESTED_WITH' @request.env.delete 'HTTP_ACCEPT' end + @request.query_string = '' @response end @@ -554,7 +558,7 @@ module ActionController def scrub_env!(env) env.delete_if { |k, v| k =~ /^(action_dispatch|rack)\.request/ } env.delete_if { |k, v| k =~ /^action_dispatch\.rescue/ } - env['action_dispatch.request.query_parameters'] = {} + env.delete 'action_dispatch.request.query_parameters' env end @@ -613,11 +617,10 @@ module ActionController :relative_url_root => nil, :_recall => @request.path_parameters) - url, query_string = @routes.path_for(options).split("?", 2) + url, = @routes.path_for(options).split("?", 2) @request.env["SCRIPT_NAME"] = @controller.config.relative_url_root @request.env["PATH_INFO"] = url - @request.env["QUERY_STRING"] = query_string || "" end end diff --git a/actionpack/test/controller/test_case_test.rb b/actionpack/test/controller/test_case_test.rb index 5c9f9b654a..de997bf954 100644 --- a/actionpack/test/controller/test_case_test.rb +++ b/actionpack/test/controller/test_case_test.rb @@ -562,7 +562,7 @@ XML parsed_params = ::JSON.parse(@response.body) assert_equal( {'controller' => 'test_case_test/test', 'action' => 'test_params', - 'format' => 'json', 'count' => 999 }, + 'format' => 'json', 'count' => '999' }, parsed_params ) end |