Skip to content

Commit

Permalink
Reset request_parameters in TestRequest#recycle! to avoid multiple po…
Browse files Browse the repository at this point in the history
…sts clobbering each other [#2271 state:resolved]

Signed-off-by: Joshua Peek <josh@joshpeek.com>
  • Loading branch information
Peter Marklund authored and josh committed Mar 24, 2009
1 parent c919127 commit daffa5c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions actionpack/lib/action_controller/test_process.rb
Expand Up @@ -110,6 +110,7 @@ def assign_parameters(controller_path, action, parameters)
end

def recycle!
@env["action_controller.request.request_parameters"] = {}
self.query_parameters = {}
self.path_parameters = {}
@headers, @request_method, @accepts, @content_type = nil, nil, nil, nil
Expand Down
8 changes: 8 additions & 0 deletions actionpack/test/controller/test_test.rb
Expand Up @@ -515,6 +515,14 @@ def test_header_properly_reset_after_get_request
assert_nil @request.instance_variable_get("@request_method")
end

def test_params_reset_after_post_request
post :no_op, :foo => "bar"
assert_equal "bar", @request.params[:foo]
@request.recycle!
post :no_op
assert @request.params[:foo].blank?
end

%w(controller response request).each do |variable|
%w(get post put delete head process).each do |method|
define_method("test_#{variable}_missing_for_#{method}_raises_error") do
Expand Down

0 comments on commit daffa5c

Please sign in to comment.