From 5ea8efecd08a71ca78688105a39b8a94236443ed Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 8 Jul 2015 16:41:46 -0700 Subject: 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` --- actionpack/lib/action_controller/test_case.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'actionpack/lib') 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 -- cgit v1.2.3