Permalink
Browse files

Reset symbolized path parameters when a test request is recycled [#5437

… state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
1 parent 6579173 commit 78486cb9c5f25f0470114989df25894599b27329 @pixeltrix pixeltrix committed with josevalim Aug 24, 2010
View
1 actionpack/lib/action_controller/test_case.rb
@@ -167,6 +167,7 @@ def recycle!
@formats = nil
@env.delete_if { |k, v| k =~ /^(action_dispatch|rack)\.request/ }
@env.delete_if { |k, v| k =~ /^action_dispatch\.rescue/ }
+ @symbolized_path_params = nil
@method = @request_method = nil
@fullpath = @ip = @remote_ip = nil
@env['action_dispatch.request.query_parameters'] = {}
View
4 actionpack/lib/action_dispatch/http/parameters.rb
@@ -15,14 +15,14 @@ def parameters
alias :params :parameters
def path_parameters=(parameters) #:nodoc:
- @_symbolized_path_params = nil
+ @symbolized_path_params = nil
@env.delete("action_dispatch.request.parameters")
@env["action_dispatch.request.path_parameters"] = parameters
end
# The same as <tt>path_parameters</tt> with explicitly symbolized keys.
def symbolized_path_parameters
- @_symbolized_path_params ||= path_parameters.symbolize_keys
+ @symbolized_path_params ||= path_parameters.symbolize_keys
end
# Returns a hash with the \parameters used to form the \path of the request.
View
8 actionpack/test/controller/test_test.rb
@@ -549,6 +549,14 @@ def test_params_reset_after_post_request
assert_blank @request.params[:foo]
end
+ def test_symbolized_path_params_reset_after_request
+ get :test_params, :id => "foo"
+ assert_equal "foo", @request.symbolized_path_parameters[:id]
+ @request.recycle!
+ get :test_params
+ assert_nil @request.symbolized_path_parameters[:id]
+ end
+
def test_should_have_knowledge_of_client_side_cookie_state_even_if_they_are_not_set
@request.cookies['foo'] = 'bar'
get :no_op

0 comments on commit 78486cb

Please sign in to comment.