diff --git a/lib/rack/test.rb b/lib/rack/test.rb index e24b0f8d..c2d8ba61 100644 --- a/lib/rack/test.rb +++ b/lib/rack/test.rb @@ -211,7 +211,7 @@ def follow_redirect! raise Error, 'Last response was not a redirect. Cannot follow_redirect!' end - if last_response.status == 307 + if last_response.status == 307 || last_response.status == 308 request_method = last_request.request_method params = last_request.params else diff --git a/spec/rack/test_spec.rb b/spec/rack/test_spec.rb index e74469c1..2108fa9a 100644 --- a/spec/rack/test_spec.rb +++ b/spec/rack/test_spec.rb @@ -497,6 +497,14 @@ def convert_input_hash_to_string(value) end.must_raise(Rack::Test::Error) end + + it 'keeps the original method and params for HTTP 308' do + post '/redirect?status=308', foo: 'bar' + follow_redirect! + last_response.body.must_include 'post' + last_response.body.must_include 'foo' + last_response.body.must_include 'bar' + end it 'keeps the original method and params for HTTP 307' do post '/redirect?status=307', foo: 'bar' follow_redirect!