-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the capability to show a single article and fix errors in multiline fixtures to make controller test assertsions pass. * Add the Articles show route * Add the show action to the ArticlesController * Add the show.html.erb view * Modify the index view to link to each article * Fix the fixtures to properly fold multiline text for the Article body Completes Rails Getting Started Guide: * 7 CRUDit Where CRUDit Is Due * 7.1 Showing a Single Article
- Loading branch information
1 parent
08201fe
commit c2debae
Showing
6 changed files
with
24 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<h1><%= @article.title %></h1> | ||
|
||
<p><%= @article.body %></p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
root "articles#index" | ||
|
||
get "/articles", to: "articles#index" | ||
get "/articles/:id", to: "articles#show" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
require "test_helper" | ||
|
||
class ArticlesControllerTest < ActionDispatch::IntegrationTest | ||
def setup | ||
@article = articles(:nerd) | ||
end | ||
|
||
test "should get index" do | ||
get articles_url | ||
assert_response :success | ||
assert_select 'h1', 'Articles' | ||
assert_select 'li', Article.count | ||
end | ||
|
||
test "should get show" do | ||
get "/articles/#{@article.id}" | ||
assert_response :success | ||
assert_select 'h1', @article.title | ||
assert_select 'p', @article.body | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters