diff options
author | Rafael França <rafael@franca.dev> | 2019-07-25 13:43:08 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-25 13:43:08 -0400 |
commit | 8ff7efef6c102c6668c7f29e839af7da6663f7c6 (patch) | |
tree | 9817491b7ab8656e359328e1c8758b43d6b3159d /actionpack/lib | |
parent | 53d9bb9a92c32a6dffdadd534bcb6c6d5e223b91 (diff) | |
parent | 1969f40a3a0aa7393b4815b7f7227c79f28b343a (diff) | |
download | rails-8ff7efef6c102c6668c7f29e839af7da6663f7c6.tar.gz rails-8ff7efef6c102c6668c7f29e839af7da6663f7c6.tar.bz2 rails-8ff7efef6c102c6668c7f29e839af7da6663f7c6.zip |
Merge pull request #34201 from Edouard-chin/ec-follow-redirect-307
fix `follow_redirect!` not using the same HTTP verb on 307 redirection:
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/testing/integration.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/actionpack/lib/action_dispatch/testing/integration.rb b/actionpack/lib/action_dispatch/testing/integration.rb index c5f8b816a4..9e7b4301a8 100644 --- a/actionpack/lib/action_dispatch/testing/integration.rb +++ b/actionpack/lib/action_dispatch/testing/integration.rb @@ -49,11 +49,16 @@ module ActionDispatch # Follow a single redirect response. If the last response was not a # redirect, an exception will be raised. Otherwise, the redirect is - # performed on the location header. Any arguments are passed to the - # underlying call to `get`. + # performed on the location header. If the redirection is a 307 redirect, + # the same HTTP verb will be used when redirecting, otherwise a GET request + # will be performed. Any arguments are passed to the + # underlying request. def follow_redirect!(**args) raise "not a redirect! #{status} #{status_message}" unless redirect? - get(response.location, **args) + + method = response.status == 307 ? request.method.downcase : :get + public_send(method, response.location, **args) + status end end |