mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #24701 from prathamesh-sonpatki/deprecate-request_via_redirect
Deprecate `request_via_redirect` method.
This commit is contained in:
commit
65d743904c
2 changed files with 11 additions and 8 deletions
|
@ -122,6 +122,7 @@ module ActionDispatch
|
||||||
# params: { ref_id: 14 },
|
# params: { ref_id: 14 },
|
||||||
# headers: { "X-Test-Header" => "testvalue" }
|
# headers: { "X-Test-Header" => "testvalue" }
|
||||||
def request_via_redirect(http_method, path, *args)
|
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)
|
process_with_kwargs(http_method, path, *args)
|
||||||
|
|
||||||
follow_redirect! while redirect?
|
follow_redirect! while redirect?
|
||||||
|
@ -131,35 +132,35 @@ module ActionDispatch
|
||||||
# Performs a GET request, following any subsequent redirect.
|
# Performs a GET request, following any subsequent redirect.
|
||||||
# See +request_via_redirect+ for more information.
|
# See +request_via_redirect+ for more information.
|
||||||
def get_via_redirect(path, *args)
|
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.')
|
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)
|
request_via_redirect(:get, path, *args)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Performs a POST request, following any subsequent redirect.
|
# Performs a POST request, following any subsequent redirect.
|
||||||
# See +request_via_redirect+ for more information.
|
# See +request_via_redirect+ for more information.
|
||||||
def post_via_redirect(path, *args)
|
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.')
|
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)
|
request_via_redirect(:post, path, *args)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Performs a PATCH request, following any subsequent redirect.
|
# Performs a PATCH request, following any subsequent redirect.
|
||||||
# See +request_via_redirect+ for more information.
|
# See +request_via_redirect+ for more information.
|
||||||
def patch_via_redirect(path, *args)
|
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.')
|
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)
|
request_via_redirect(:patch, path, *args)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Performs a PUT request, following any subsequent redirect.
|
# Performs a PUT request, following any subsequent redirect.
|
||||||
# See +request_via_redirect+ for more information.
|
# See +request_via_redirect+ for more information.
|
||||||
def put_via_redirect(path, *args)
|
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.')
|
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)
|
request_via_redirect(:put, path, *args)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Performs a DELETE request, following any subsequent redirect.
|
# Performs a DELETE request, following any subsequent redirect.
|
||||||
# See +request_via_redirect+ for more information.
|
# See +request_via_redirect+ for more information.
|
||||||
def delete_via_redirect(path, *args)
|
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.')
|
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)
|
request_via_redirect(:delete, path, *args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -35,7 +35,7 @@ class SessionTest < ActiveSupport::TestCase
|
||||||
path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue"}
|
path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue"}
|
||||||
assert_called_with @session, :process, [:put, path, params: args, headers: headers] do
|
assert_called_with @session, :process, [:put, path, params: args, headers: headers] do
|
||||||
@session.stub :redirect?, false do
|
@session.stub :redirect?, false do
|
||||||
@session.request_via_redirect(:put, path, params: args, headers: headers)
|
assert_deprecated { @session.request_via_redirect(:put, path, params: args, headers: headers) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -54,7 +54,7 @@ class SessionTest < ActiveSupport::TestCase
|
||||||
value_series = [true, true, false]
|
value_series = [true, true, false]
|
||||||
assert_called @session, :follow_redirect!, times: 2 do
|
assert_called @session, :follow_redirect!, times: 2 do
|
||||||
@session.stub :redirect?, ->{ value_series.shift } do
|
@session.stub :redirect?, ->{ value_series.shift } do
|
||||||
@session.request_via_redirect(:get, path, params: args, headers: headers)
|
assert_deprecated { @session.request_via_redirect(:get, path, params: args, headers: headers) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -63,7 +63,9 @@ class SessionTest < ActiveSupport::TestCase
|
||||||
path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue"}
|
path = "/somepath"; args = {:id => '1'}; headers = {"X-Test-Header" => "testvalue"}
|
||||||
@session.stub :redirect?, false do
|
@session.stub :redirect?, false do
|
||||||
@session.stub :status, 200 do
|
@session.stub :status, 200 do
|
||||||
assert_equal 200, @session.request_via_redirect(:get, path, params: args, headers: headers)
|
assert_deprecated do
|
||||||
|
assert_equal 200, @session.request_via_redirect(:get, path, params: args, headers: headers)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue