diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2015-07-08 16:41:46 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2015-07-08 16:43:58 -0700 |
commit | 5ea8efecd08a71ca78688105a39b8a94236443ed (patch) | |
tree | fde8263f337075520bad0f9fe8017dddd0b4c4b3 /actionpack/lib | |
parent | 2838a1f4acccd2849e7b84cbdb140c13b649e211 (diff) | |
download | rails-5ea8efecd08a71ca78688105a39b8a94236443ed.tar.gz rails-5ea8efecd08a71ca78688105a39b8a94236443ed.tar.bz2 rails-5ea8efecd08a71ca78688105a39b8a94236443ed.zip |
build and assign parameters rather than rely on mutations
We should assign parameters to the request object rather than mutate the
hash that is returned by `query_parameters` or `request_parameters`
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/test_case.rb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index 788fc9fe7d..aec21eb35e 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -34,10 +34,18 @@ module ActionController self.session_options = TestSession::DEFAULT_OPTIONS end + def query_parameters=(params) + @env["action_dispatch.request.query_parameters"] = params + end + + def request_parameters=(params) + @env["action_dispatch.request.request_parameters"] = params + end + def assign_parameters(routes, controller_path, action, parameters = {}) parameters = parameters.symbolize_keys extra_keys = routes.extra_keys(parameters.merge(:controller => controller_path, :action => action)) - non_path_parameters = get? ? query_parameters : request_parameters + non_path_parameters = {}.with_indifferent_access parameters.each do |key, value| if value.is_a?(Array) && (value.frozen? || value.any?(&:frozen?)) @@ -61,6 +69,12 @@ module ActionController end end + if get? + self.query_parameters = non_path_parameters + else + self.request_parameters = non_path_parameters + end + path_parameters[:controller] = controller_path path_parameters[:action] = action |