Skip to content

Commit

Permalink
Don't assume post with params will preserve input body.
Browse files Browse the repository at this point in the history
Rack 3 drops the requirement for input bodies to be rewindable, and
params, once read, may not be available for "raw_post". Update the tests
to prefer to use raw "body:" rather than "params:" which can be consumed
by Rack::Request in Rack 3.
  • Loading branch information
ioquatix committed Jun 13, 2023
1 parent 84540a6 commit 9b1f88a
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions actionpack/test/controller/test_case_test.rb
Expand Up @@ -236,10 +236,10 @@ def test_url_options_reset
end

def test_raw_post_handling
params = Hash[:page, { name: "page name" }, "some key", 123]
post :render_raw_post, params: params.dup
body = "Hello World"
post :render_raw_post, body: body

assert_equal params.to_query, @response.body
assert_equal body, @response.body
end

def test_params_round_trip
Expand All @@ -263,11 +263,11 @@ def to_param
end

def test_body_stream
params = Hash[:page, { name: "page name" }, "some key", 123]
body = "Hello World"

post :render_body, params: params.dup
post :render_body, body: body

assert_equal params.to_query, @response.body
assert_equal body, @response.body
end

def test_document_body_and_params_with_post
Expand Down Expand Up @@ -751,10 +751,10 @@ def test_filtered_parameters_reset_between_requests
end

def test_raw_post_reset_between_post_requests
post :no_op, params: { foo: "bar" }
post :no_op, body: "foo=bar"
assert_equal "foo=bar", @request.raw_post

post :no_op, params: { foo: "baz" }
post :no_op, body: "foo=baz"
assert_equal "foo=baz", @request.raw_post
end

Expand Down

0 comments on commit 9b1f88a

Please sign in to comment.