aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorप्रथमेश Sonpatki <csonpatki@gmail.com>2016-09-24 00:15:21 +0530
committerGitHub <noreply@github.com>2016-09-24 00:15:21 +0530
commit780058ba1e781afdd76fb6c0732b5b883aa8daae (patch)
tree8bd96d7feb3e5299f4dc74a60fa32cf84c917a17
parentda8cd519ad8265660382f9b91d7ddee4309ef4ca (diff)
parentb8c74e77f26bb330eb3ecf917e3c2ef8a5f2d566 (diff)
downloadrails-780058ba1e781afdd76fb6c0732b5b883aa8daae.tar.gz
rails-780058ba1e781afdd76fb6c0732b5b883aa8daae.tar.bz2
rails-780058ba1e781afdd76fb6c0732b5b883aa8daae.zip
Merge pull request #26605 from mjhoy/fix-controller-tests-guides-get-action
Fix docs for allowed params to `get` in controller tests [ci skip]
-rw-r--r--guides/source/testing.md8
1 files changed, 4 insertions, 4 deletions
diff --git a/guides/source/testing.md b/guides/source/testing.md
index 8f9246dea2..98847fde18 100644
--- a/guides/source/testing.md
+++ b/guides/source/testing.md
@@ -761,8 +761,8 @@ and also ensuring that the right response body has been generated.
The `get` method kicks off the web request and populates the results into the `@response`. It can accept up to 6 arguments:
-* The action of the controller you are requesting.
- This can be in the form of a string or a route (i.e. `articles_url`).
+* The URI of the controller action you are requesting.
+ This can be in the form of a string or a route helper (e.g. `articles_url`).
* `params`: option with a hash of request parameters to pass into the action
(e.g. query string parameters or article variables).
* `headers`: for setting the headers that will be passed with the request.
@@ -775,13 +775,13 @@ All of these keyword arguments are optional.
Example: Calling the `:show` action, passing an `id` of 12 as the `params` and setting `HTTP_REFERER` header:
```ruby
-get :show, params: { id: 12 }, headers: { "HTTP_REFERER" => "http://example.com/home" }
+get article_url, params: { id: 12 }, headers: { "HTTP_REFERER" => "http://example.com/home" }
```
Another example: Calling the `:update` action, passing an `id` of 12 as the `params` as an Ajax request.
```ruby
-patch update_url, params: { id: 12 }, xhr: true
+patch article_url, params: { id: 12 }, xhr: true
```
NOTE: If you try running `test_should_create_article` test from `articles_controller_test.rb` it will fail on account of the newly added model level validation and rightly so.