mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Remove deprecated ActionDispatch::IntegrationTest#*_via_redirect
.
This commit is contained in:
parent
eb52e5d42f
commit
092033d59f
3 changed files with 4 additions and 142 deletions
|
@ -1,3 +1,7 @@
|
|||
* Remove deprecated `ActionDispatch::IntegrationTest#*_via_redirect`.
|
||||
|
||||
*Rafael Mendonça França*
|
||||
|
||||
* Remove deprecated `ActionDispatch::IntegrationTest#xml_http_request`.
|
||||
|
||||
*Rafael Mendonça França*
|
||||
|
|
|
@ -80,59 +80,6 @@ module ActionDispatch
|
|||
get(response.location)
|
||||
status
|
||||
end
|
||||
|
||||
# Performs a request using the specified method, following any subsequent
|
||||
# redirect. Note that the redirects are followed until the response is
|
||||
# not a redirect--this means you may run into an infinite loop if your
|
||||
# redirect loops back to itself.
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# request_via_redirect :post, '/welcome',
|
||||
# params: { ref_id: 14 },
|
||||
# headers: { "X-Test-Header" => "testvalue" }
|
||||
def request_via_redirect(http_method, path, *args)
|
||||
ActiveSupport::Deprecation.warn("`request_via_redirect` is deprecated and will be removed in Rails 5.1. Please use `follow_redirect!` manually after the request call for the same behavior.")
|
||||
process_with_kwargs(http_method, path, *args)
|
||||
|
||||
follow_redirect! while redirect?
|
||||
status
|
||||
end
|
||||
|
||||
# Performs a GET request, following any subsequent redirect.
|
||||
# See +request_via_redirect+ for more information.
|
||||
def get_via_redirect(path, *args)
|
||||
ActiveSupport::Deprecation.warn("`get_via_redirect` is deprecated and will be removed in Rails 5.1. Please use `follow_redirect!` manually after the request call for the same behavior.")
|
||||
request_via_redirect(:get, path, *args)
|
||||
end
|
||||
|
||||
# Performs a POST request, following any subsequent redirect.
|
||||
# See +request_via_redirect+ for more information.
|
||||
def post_via_redirect(path, *args)
|
||||
ActiveSupport::Deprecation.warn("`post_via_redirect` is deprecated and will be removed in Rails 5.1. Please use `follow_redirect!` manually after the request call for the same behavior.")
|
||||
request_via_redirect(:post, path, *args)
|
||||
end
|
||||
|
||||
# Performs a PATCH request, following any subsequent redirect.
|
||||
# See +request_via_redirect+ for more information.
|
||||
def patch_via_redirect(path, *args)
|
||||
ActiveSupport::Deprecation.warn("`patch_via_redirect` is deprecated and will be removed in Rails 5.1. Please use `follow_redirect!` manually after the request call for the same behavior.")
|
||||
request_via_redirect(:patch, path, *args)
|
||||
end
|
||||
|
||||
# Performs a PUT request, following any subsequent redirect.
|
||||
# See +request_via_redirect+ for more information.
|
||||
def put_via_redirect(path, *args)
|
||||
ActiveSupport::Deprecation.warn("`put_via_redirect` is deprecated and will be removed in Rails 5.1. Please use `follow_redirect!` manually after the request call for the same behavior.")
|
||||
request_via_redirect(:put, path, *args)
|
||||
end
|
||||
|
||||
# Performs a DELETE request, following any subsequent redirect.
|
||||
# See +request_via_redirect+ for more information.
|
||||
def delete_via_redirect(path, *args)
|
||||
ActiveSupport::Deprecation.warn("`delete_via_redirect` is deprecated and will be removed in Rails 5.1. Please use `follow_redirect!` manually after the request call for the same behavior.")
|
||||
request_via_redirect(:delete, path, *args)
|
||||
end
|
||||
end
|
||||
|
||||
# An instance of this class represents a set of requests and responses
|
||||
|
|
|
@ -31,95 +31,6 @@ class SessionTest < ActiveSupport::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_request_via_redirect_uses_given_method
|
||||
path = "/somepath"; args = { id: "1" }; headers = { "X-Test-Header" => "testvalue" }
|
||||
assert_called_with @session, :process, [:put, path, params: args, headers: headers] do
|
||||
@session.stub :redirect?, false do
|
||||
assert_deprecated { @session.request_via_redirect(:put, path, params: args, headers: headers) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_deprecated_request_via_redirect_uses_given_method
|
||||
path = "/somepath"; args = { id: "1" }; headers = { "X-Test-Header" => "testvalue" }
|
||||
assert_called_with @session, :process, [:put, path, params: args, headers: headers] do
|
||||
@session.stub :redirect?, false do
|
||||
assert_deprecated { @session.request_via_redirect(:put, path, args, headers) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_request_via_redirect_follows_redirects
|
||||
path = "/somepath"; args = { id: "1" }; headers = { "X-Test-Header" => "testvalue" }
|
||||
value_series = [true, true, false]
|
||||
assert_called @session, :follow_redirect!, times: 2 do
|
||||
@session.stub :redirect?, -> { value_series.shift } do
|
||||
assert_deprecated { @session.request_via_redirect(:get, path, params: args, headers: headers) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_request_via_redirect_returns_status
|
||||
path = "/somepath"; args = { id: "1" }; headers = { "X-Test-Header" => "testvalue" }
|
||||
@session.stub :redirect?, false do
|
||||
@session.stub :status, 200 do
|
||||
assert_deprecated do
|
||||
assert_equal 200, @session.request_via_redirect(:get, path, params: args, headers: headers)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_deprecated_get_via_redirect
|
||||
path = "/somepath"; args = { id: "1" }; headers = { "X-Test-Header" => "testvalue" }
|
||||
|
||||
assert_called_with @session, :request_via_redirect, [:get, path, args, headers] do
|
||||
assert_deprecated do
|
||||
@session.get_via_redirect(path, args, headers)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_deprecated_post_via_redirect
|
||||
path = "/somepath"; args = { id: "1" }; headers = { "X-Test-Header" => "testvalue" }
|
||||
|
||||
assert_called_with @session, :request_via_redirect, [:post, path, args, headers] do
|
||||
assert_deprecated do
|
||||
@session.post_via_redirect(path, args, headers)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_deprecated_patch_via_redirect
|
||||
path = "/somepath"; args = { id: "1" }; headers = { "X-Test-Header" => "testvalue" }
|
||||
|
||||
assert_called_with @session, :request_via_redirect, [:patch, path, args, headers] do
|
||||
assert_deprecated do
|
||||
@session.patch_via_redirect(path, args, headers)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_deprecated_put_via_redirect
|
||||
path = "/somepath"; args = { id: "1" }; headers = { "X-Test-Header" => "testvalue" }
|
||||
|
||||
assert_called_with @session, :request_via_redirect, [:put, path, args, headers] do
|
||||
assert_deprecated do
|
||||
@session.put_via_redirect(path, args, headers)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_deprecated_delete_via_redirect
|
||||
path = "/somepath"; args = { id: "1" }; headers = { "X-Test-Header" => "testvalue" }
|
||||
|
||||
assert_called_with @session, :request_via_redirect, [:delete, path, args, headers] do
|
||||
assert_deprecated do
|
||||
@session.delete_via_redirect(path, args, headers)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_get
|
||||
path = "/index"; params = "blah"; headers = { location: "blah" }
|
||||
|
||||
|
|
Loading…
Reference in a new issue