Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset CONTENT_LENGTH between test requests #32773

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions actionpack/lib/action_controller/test_case.rb
Expand Up @@ -604,6 +604,7 @@ def scrub_env!(env)
env.delete "action_dispatch.request.query_parameters"
env.delete "action_dispatch.request.request_parameters"
env["rack.input"] = StringIO.new
env.delete "CONTENT_LENGTH"
env.delete "RAW_POST_DATA"
env
end
Expand Down
8 changes: 8 additions & 0 deletions actionpack/test/controller/test_case_test.rb
Expand Up @@ -689,6 +689,14 @@ def test_raw_post_reset_between_post_requests
assert_equal "foo=baz", @request.raw_post
end

def test_content_length_reset_after_post_request
post :no_op, params: { foo: "bar" }
assert_not_equal 0, @request.content_length

get :no_op
assert_equal 0, @request.content_length
end

def test_path_is_kept_after_the_request
get :test_params, params: { id: "foo" }
assert_equal "/test_case_test/test/test_params/foo", @request.path
Expand Down