From 21575ddc32dedd358b938c6c66d0c8393a341434 Mon Sep 17 00:00:00 2001 From: Jonathan Hefner Date: Thu, 28 May 2020 01:16:40 -0500 Subject: [PATCH] Update assert_redirected_to docs [ci skip] `assert_redirected_to` does not partially match `options` anymore. That feature was removed in 3900f4007ee6463b8936af23c04017a900673866. Closes #39446. --- actionpack/lib/action_dispatch/testing/assertions/response.rb | 4 +--- guides/source/testing.md | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/actionpack/lib/action_dispatch/testing/assertions/response.rb b/actionpack/lib/action_dispatch/testing/assertions/response.rb index 8595ea03cf..2c943489cd 100644 --- a/actionpack/lib/action_dispatch/testing/assertions/response.rb +++ b/actionpack/lib/action_dispatch/testing/assertions/response.rb @@ -37,9 +37,7 @@ def assert_response(type, message = nil) end end - # Asserts that the redirection options passed in match those of the redirect called in the latest action. - # This match can be partial, such that assert_redirected_to(controller: "weblog") will also - # match the redirection of redirect_to(controller: "weblog", action: "show") and so on. + # Asserts that the response is a redirect to a URL matching the given options. # # # Asserts that the redirection was to the "index" action on the WeblogController # assert_redirected_to controller: "weblog", action: "index" diff --git a/guides/source/testing.md b/guides/source/testing.md index 0ebf8ca6c4..59b8c0e983 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -358,7 +358,7 @@ Rails adds some custom assertions of its own to the `minitest` framework: | [`assert_recognizes(expected_options, path, extras={}, message=nil)`](https://api.rubyonrails.org/classes/ActionDispatch/Assertions/RoutingAssertions.html#method-i-assert_recognizes) | Asserts that the routing of the given path was handled correctly and that the parsed options (given in the expected_options hash) match path. Basically, it asserts that Rails recognizes the route given by expected_options.| | [`assert_generates(expected_path, options, defaults={}, extras = {}, message=nil)`](https://api.rubyonrails.org/classes/ActionDispatch/Assertions/RoutingAssertions.html#method-i-assert_generates) | Asserts that the provided options can be used to generate the provided path. This is the inverse of assert_recognizes. The extras parameter is used to tell the request the names and values of additional request parameters that would be in a query string. The message parameter allows you to specify a custom error message for assertion failures.| | [`assert_response(type, message = nil)`](https://api.rubyonrails.org/classes/ActionDispatch/Assertions/ResponseAssertions.html#method-i-assert_response) | Asserts that the response comes with a specific status code. You can specify `:success` to indicate 200-299, `:redirect` to indicate 300-399, `:missing` to indicate 404, or `:error` to match the 500-599 range. You can also pass an explicit status number or its symbolic equivalent. For more information, see [full list of status codes](http://rubydoc.info/github/rack/rack/master/Rack/Utils#HTTP_STATUS_CODES-constant) and how their [mapping](https://rubydoc.info/github/rack/rack/master/Rack/Utils#SYMBOL_TO_STATUS_CODE-constant) works.| -| [`assert_redirected_to(options = {}, message=nil)`](https://api.rubyonrails.org/classes/ActionDispatch/Assertions/ResponseAssertions.html#method-i-assert_redirected_to) | Asserts that the redirection options passed in match those of the redirect called in the latest action. This match can be partial, such that `assert_redirected_to(controller: "weblog")` will also match the redirection of `redirect_to(controller: "weblog", action: "show")` and so on. You can also pass named routes such as `assert_redirected_to root_path` and Active Record objects such as `assert_redirected_to @article`.| +| [`assert_redirected_to(options = {}, message=nil)`](https://api.rubyonrails.org/classes/ActionDispatch/Assertions/ResponseAssertions.html#method-i-assert_redirected_to) | Asserts that the response is a redirect to a URL matching the given options. You can also pass named routes such as `assert_redirected_to root_path` and Active Record objects such as `assert_redirected_to @article`.| You'll see the usage of some of these assertions in the next chapter. -- GitLab