Skip to content

Commit 2c1ae85

Browse files
committed
Finish static pages
1 parent e45da59 commit 2c1ae85

File tree

7 files changed

+84
-5
lines changed

7 files changed

+84
-5
lines changed

app/controllers/static_pages_controller.rb

+4
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,8 @@ def home
44

55
def help
66
end
7+
8+
def about
9+
end
10+
711
end

app/views/layouts/application.html.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<title>SampleApp</title>
4+
<title>Ruby on Rails Tutorial Sample App | <%= yield(:title) %></title>
55
<%= stylesheet_link_tag "application", :media => "all" %>
66
<%= javascript_include_tag "application" %>
77
<%= csrf_meta_tags %>

app/views/static_pages/about.html.erb

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<% provide(:title, 'About Us') %>
2+
<h1>About Us</h1>
3+
<p>
4+
The <a href="http://railstutorial.org/">Ruby on Rails Tutorial</a>
5+
is a project to make a book and screencasts to teach web development
6+
with <a href="http://rubyonrails.org/">Ruby on Rails</a>. This
7+
is the sample application for the tutorial.
8+
</p>

app/views/static_pages/help.html.erb

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,16 @@
1-
<h1>StaticPages#help</h1>
2-
<p>Find me in app/views/static_pages/help.html.erb</p>
1+
<% provide(:title, 'Help') %>
2+
<!DOCTYPE html>
3+
<html>
4+
<head>
5+
<title>Ruby on Rails Tutorial Sample App | <%= yield(:title) %></title>
6+
</head>
7+
<body>
8+
<h1>Help</h1>
9+
<p>
10+
Get help on the Ruby on Rails Tutorial at the
11+
<a href="http://railstutorial.org/help">Rails Tutorial help page</a>.
12+
To get help on this sample app, see the
13+
<a href="http://railstutorial.org/book">Rails Tutorial book</a>.
14+
</p>
15+
</body>
16+
</html>

app/views/static_pages/home.html.erb

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1-
<h1>StaticPages#home</h1>
2-
<p>Find me in app/views/static_pages/home.html.erb</p>
1+
<% provide(:title, 'Home') %>
2+
<h1>Sample App</h1>
3+
<p>
4+
This is the home page for the
5+
<a href="http://railstutorial.org/">Ruby on Rails Tutorial</a>
6+
sample application.
7+
</p>

config/routes.rb

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
get "static_pages/help"
55

6+
get "static_pages/about"
7+
68
# The priority is based upon order of creation:
79
# first created -> highest priority.
810

spec/requests/static_pages_spec.rb

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
require 'spec_helper'
2+
3+
describe "Static pages" do
4+
5+
describe "Home page" do
6+
7+
it "should have the h1 'Sample App'" do
8+
visit '/static_pages/home'
9+
page.should have_selector('h1', :text => 'Sample App')
10+
end
11+
12+
it "should have the title 'Home'" do
13+
visit '/static_pages/home'
14+
page.should have_selector('title',
15+
:text => "Ruby on Rails Tutorial Sample App | Home")
16+
end
17+
end
18+
19+
describe "Help page" do
20+
21+
it "should have the h1 'Help'" do
22+
visit '/static_pages/help'
23+
page.should have_selector('h1', :text => 'Help')
24+
end
25+
26+
it "should have the title 'Help'" do
27+
visit '/static_pages/help'
28+
page.should have_selector('title',
29+
:text => "Ruby on Rails Tutorial Sample App | Help")
30+
end
31+
end
32+
33+
describe "About page" do
34+
35+
it "should have the h1 'About Us'" do
36+
visit '/static_pages/about'
37+
page.should have_selector('h1', :text => 'About Us')
38+
end
39+
40+
it "should have the title 'About Us'" do
41+
visit '/static_pages/about'
42+
page.should have_selector('title',
43+
:text => "Ruby on Rails Tutorial Sample App | About Us")
44+
end
45+
end
46+
end

0 commit comments

Comments
 (0)