diff options
Diffstat (limited to 'actionpack/test/controller/integration_test.rb')
-rw-r--r-- | actionpack/test/controller/integration_test.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb index 97571c1308..e02b0b267d 100644 --- a/actionpack/test/controller/integration_test.rb +++ b/actionpack/test/controller/integration_test.rb @@ -625,6 +625,20 @@ class IntegrationProcessTest < ActionDispatch::IntegrationTest end end + def test_post_then_get_with_parameters_do_not_leak_across_requests + with_test_route_set do + post '/post', params: { leaks: "does-leak?" } + + get '/get_with_params', params: { foo: "bar" } + + assert request.env['rack.input'].string.empty? + assert_equal 'foo=bar', request.env["QUERY_STRING"] + assert_equal 'foo=bar', request.query_string + assert_equal 'bar', request.parameters['foo'] + assert request.parameters['leaks'].nil? + end + end + def test_head with_test_route_set do head '/get' @@ -1147,6 +1161,22 @@ class IntegrationRequestEncodersTest < ActionDispatch::IntegrationTest end end + def test_standard_json_encoding_works + with_routing do |routes| + routes.draw do + ActiveSupport::Deprecation.silence do + post ':action' => FooController + end + end + + post '/foos_json.json', params: { foo: 'fighters' }.to_json, + headers: { 'Content-Type' => 'application/json' } + + assert_response :success + assert_equal({ 'foo' => 'fighters' }, response.parsed_body) + end + end + def test_encoding_as_json post_to_foos as: :json do assert_response :success @@ -1194,6 +1224,20 @@ class IntegrationRequestEncodersTest < ActionDispatch::IntegrationTest end end + def test_get_parameters_with_as_option + with_routing do |routes| + routes.draw do + ActiveSupport::Deprecation.silence do + get ':action' => FooController + end + end + + get '/foos_json?foo=heyo', as: :json + + assert_equal({ 'foo' => 'heyo' }, response.parsed_body) + end + end + private def post_to_foos(as:) with_routing do |routes| |