diff options
author | Andrew White <andyw@pixeltrix.co.uk> | 2014-01-27 09:08:56 +0000 |
---|---|---|
committer | Andrew White <andyw@pixeltrix.co.uk> | 2014-01-27 13:30:28 +0000 |
commit | 31616068032beb537768787ff3a206b062eb192e (patch) | |
tree | c78d327d742a844a2ce4f0598fa8aa320986d76c /actionpack/test | |
parent | 9673d5df2764f8a2f84fc739b480f3040926c0cd (diff) | |
download | rails-31616068032beb537768787ff3a206b062eb192e.tar.gz rails-31616068032beb537768787ff3a206b062eb192e.tar.bz2 rails-31616068032beb537768787ff3a206b062eb192e.zip |
Clear filtered request attributes between requests in tests
The request attributes filtered_parameters, filtered_env and filtered_path
are memoized for performance reasons. However this can cause unusual
behavior in tests where there are multiple calls to get, post, etc.
Fixes #13803.
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/log_subscriber_test.rb | 11 | ||||
-rw-r--r-- | actionpack/test/controller/test_case_test.rb | 8 |
2 files changed, 19 insertions, 0 deletions
diff --git a/actionpack/test/controller/log_subscriber_test.rb b/actionpack/test/controller/log_subscriber_test.rb index 075347be52..18037b3d2f 100644 --- a/actionpack/test/controller/log_subscriber_test.rb +++ b/actionpack/test/controller/log_subscriber_test.rb @@ -137,6 +137,17 @@ class ACLogSubscriberTest < ActionController::TestCase assert_equal 'Parameters: {"id"=>"10"}', logs[1] end + def test_multiple_process_with_parameters + get :show, :id => '10' + get :show, :id => '20' + + wait + + assert_equal 6, logs.size + assert_equal 'Parameters: {"id"=>"10"}', logs[1] + assert_equal 'Parameters: {"id"=>"20"}', logs[4] + end + def test_process_action_with_wrapped_parameters @request.env['CONTENT_TYPE'] = 'application/json' post :show, :id => '10', :name => 'jose' diff --git a/actionpack/test/controller/test_case_test.rb b/actionpack/test/controller/test_case_test.rb index de0476dbde..5ff4a383ec 100644 --- a/actionpack/test/controller/test_case_test.rb +++ b/actionpack/test/controller/test_case_test.rb @@ -706,6 +706,14 @@ XML assert @request.params[:foo].blank? end + def test_filtered_parameters_reset_between_requests + get :no_op, :foo => "bar" + assert_equal "bar", @request.filtered_parameters[:foo] + + get :no_op, :foo => "baz" + assert_equal "baz", @request.filtered_parameters[:foo] + end + def test_symbolized_path_params_reset_after_request get :test_params, :id => "foo" assert_equal "foo", @request.symbolized_path_parameters[:id] |