diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index 442ffd6d7c766..f216d19ac39ab 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -601,6 +601,7 @@ def scrub_env!(env) env.delete_if { |k, v| k =~ /^action_dispatch\.rescue/ } env.delete 'action_dispatch.request.query_parameters' env.delete 'action_dispatch.request.request_parameters' + env.delete 'PATH_INFO' env end diff --git a/actionpack/test/controller/test_case_test.rb b/actionpack/test/controller/test_case_test.rb index e50373a0cc447..619e709d85652 100644 --- a/actionpack/test/controller/test_case_test.rb +++ b/actionpack/test/controller/test_case_test.rb @@ -150,6 +150,14 @@ def test_with_body render html: ''.html_safe end + def path_one + render plain: request.fullpath + end + + def path_two + render plain: request.fullpath + end + private def generate_url(opts) @@ -966,6 +974,14 @@ def test_redirect_url_only_cares_about_location_header assert_redirected_to 'created resource' end end + + def test_request_path_correct + get :path_one + assert_equal "/test_case_test/test/path_one", @response.body + + get :path_two + assert_equal "/test_case_test/test/path_two", @response.body + end end class ResponseDefaultHeadersTest < ActionController::TestCase