Remove deprecated support to `:back` in `redirect_to`

上级 a2762d95
* Remove deprecated support to `:back` in `redirect_to`.
*Rafael Mendonça França*
* Remove deprecated support to passing status as option `head`.
*Rafael Mendonça França*
......
......@@ -104,14 +104,6 @@ def _compute_redirect_to_location(request, options) #:nodoc:
options
when String
request.protocol + request.host_with_port + options
when :back
ActiveSupport::Deprecation.warn(<<-MESSAGE.squish)
`redirect_to :back` is deprecated and will be removed from Rails 5.1.
Please use `redirect_back(fallback_location: fallback_location)` where
`fallback_location` represents the location to use if the request has
no HTTP referer information.
MESSAGE
request.headers["Referer"] || raise(RedirectBackError)
when Proc
_compute_redirect_to_location request, options.call
else
......
......@@ -56,10 +56,6 @@ def relative_url_redirect_with_status_hash
redirect_to("/things/stuff", status: 301)
end
def redirect_to_back_with_status
redirect_to :back, status: 307
end
def redirect_back_with_status
redirect_back(fallback_location: "/things/stuff", status: 307)
end
......@@ -88,10 +84,6 @@ def redirect_to_url_with_network_path_reference
redirect_to "//www.rubyonrails.org/"
end
def redirect_to_back
redirect_to :back
end
def redirect_to_existing_record
redirect_to Workshop.new(5)
end
......@@ -206,17 +198,6 @@ def test_relative_url_redirect_with_status_hash
assert_equal "http://test.host/things/stuff", redirect_to_url
end
def test_redirect_to_back_with_status
@request.env["HTTP_REFERER"] = "http://www.example.com/coming/from"
assert_deprecated do
get :redirect_to_back_with_status
end
assert_response 307
assert_equal "http://www.example.com/coming/from", redirect_to_url
end
def test_simple_redirect_using_options
get :host_redirect
assert_response :redirect
......@@ -259,29 +240,6 @@ def test_redirect_to_url_with_network_path_reference
assert_equal "//www.rubyonrails.org/", redirect_to_url
end
def test_redirect_to_back
@request.env["HTTP_REFERER"] = "http://www.example.com/coming/from"
assert_deprecated do
get :redirect_to_back
end
assert_response :redirect
assert_equal "http://www.example.com/coming/from", redirect_to_url
end
def test_redirect_to_back_with_no_referer
assert_raise(ActionController::RedirectBackError) {
@request.env["HTTP_REFERER"] = nil
assert_deprecated do
get :redirect_to_back
end
get :redirect_to_back
}
end
def test_redirect_back
referer = "http://www.example.com/coming/from"
@request.env["HTTP_REFERER"] = referer
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册