1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

[ci skip] Add one more example to routing testing, and highlight association

name keywords
This commit is contained in:
Sandip Ransing 2014-11-14 00:35:51 +05:30 committed by Zachary Scott
parent 77ed79b842
commit 062988efd3

View file

@ -82,7 +82,7 @@ Each fixture is given a name followed by an indented list of colon-separated key
If you are working with [associations](/association_basics.html), you can simply
define a reference node between two different fixtures. Here's an example with
a belongs_to/has_many association:
a `belongs_to`/`has_many` association:
```yaml
# In fixtures/categories.yml
@ -901,13 +901,17 @@ end
Testing Routes
--------------
Like everything else in your Rails application, it is recommended that you test your routes. An example test for a route in the default `show` action of `Articles` controller above should look like:
Like everything else in your Rails application, it is recommended that you test your routes. Below are example tests for the routes of default `show` and `create` action of `Articles` controller above and it should look like:
```ruby
class ArticleRoutesTest < ActionController::TestCase
test "should route to article" do
assert_routing '/articles/1', { controller: "articles", action: "show", id: "1" }
end
test "should route to create article" do
assert_routing({ method: 'post', path: '/articles' }, { controller: "articles", action: "create" })
end
end
```