Skip to content

Commit

Permalink
Reset symbolized path parameters when a test request is recycled [#5437
Browse files Browse the repository at this point in the history
… state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information
pixeltrix authored and josevalim committed Aug 24, 2010
1 parent 6579173 commit 78486cb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions actionpack/lib/action_controller/test_case.rb
Expand Up @@ -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'] = {}
Expand Down
4 changes: 2 additions & 2 deletions actionpack/lib/action_dispatch/http/parameters.rb
Expand Up @@ -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.
Expand Down
8 changes: 8 additions & 0 deletions actionpack/test/controller/test_test.rb
Expand Up @@ -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
Expand Down

0 comments on commit 78486cb

Please sign in to comment.