提交 7a8d9649 编写于 作者: E Eugene Kenny

Reset RAW_POST_DATA between test requests

`RAW_POST_DATA` is derived from the `rack.input` header, which changes
with each test request. It needs to be cleared in `scrub_env!`, or all
requests within the same test will see the value from the first request.
上级 f6e3ca51
......@@ -460,10 +460,6 @@ def head(action, **args)
def process(action, method: "GET", params: {}, session: nil, body: nil, flash: {}, format: nil, xhr: false, as: nil)
check_required_ivars
if body
@request.set_header "RAW_POST_DATA", body
end
http_method = method.to_s.upcase
@html_document = nil
......@@ -478,6 +474,10 @@ def process(action, method: "GET", params: {}, session: nil, body: nil, flash: {
@response.request = @request
@controller.recycle!
if body
@request.set_header "RAW_POST_DATA", body
end
@request.set_header "REQUEST_METHOD", http_method
if as
......@@ -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 "RAW_POST_DATA"
env
end
......
......@@ -681,6 +681,14 @@ def test_filtered_parameters_reset_between_requests
assert_equal "baz", @request.filtered_parameters[:foo]
end
def test_raw_post_reset_between_post_requests
post :no_op, params: { foo: "bar" }
assert_equal "foo=bar", @request.raw_post
post :no_op, params: { foo: "baz" }
assert_equal "foo=baz", @request.raw_post
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册