提交 062988ef 编写于 作者: S Sandip Ransing 提交者: Zachary Scott

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

name keywords
上级 77ed79b8
......@@ -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
```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册