Skip to content

Commit

Permalink
update tests and routing. Add routing helpers.
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarnhart committed Jan 29, 2012
1 parent 585f05f commit 3fd18b6
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 13 deletions.
116 changes: 116 additions & 0 deletions app/assets/stylesheets/layout.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
$full-width: 710px;
$background-color: #cff;
$link-color: #069;
$visited-link-color: #069;

.container {
width: $full-width;
}

body {
background: $background-color;
}

header {
padding-top: 20px;

img {
padding: 1em;
background: white;
}
}

section {
margin-top: 1em;
font-size: 120%;
padding: 20px;
background-color: white;

h1 {
font-size: 200%;
}
}

/* Links */

a {
color: $link-color;
text-decoration: none;

&:hover {
color: $visited-link-color;
text-decoration: underline;
}

&:visited {
color: $visited-link-color;
}
}

/* Navigation */

nav {
float: right;
background-color: white;
padding: 0 0.7em;
white-space: nowrap;

ul {
margin: 0;
padding: 0;

li {
list-style-type: none;
display: inline-block;
padding: 0.2em 0;

a {
padding: 0 5px;
font-weight: bold;

&:visited {
color: $link-color;
}

&:hover {
text-decoration: underline;
}
}
}
}
}

/* Sign up button */

a.signup_button {
margin-left: auto;
margin-right: auto;
display: block;
text-align: center;
width: 190px;
color: white;
background: #006400;
font-size: 150%;
font-weight: bold;
padding: 20px;
}

/* Round corners */

.round {
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
}

footer {
text-align: center;
margin-top: 10px;
width: $full-width;
margin-left: auto;
margin-right: auto;

nav {
float: none;
}
}
4 changes: 0 additions & 4 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,4 @@ def full_title(page_title)
"#{base_title} | #{page_title}"
end
end

def static_page_path(page)
"/pages/" + page
end
end
4 changes: 2 additions & 2 deletions app/views/layouts/_footer.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<footer>
<nav class="round">
<ul>
<li><%= link_to "About", static_page_path('about') %></li>
<li><%= link_to "Contact", static_page_path('about') %></li>
<li><%= link_to "About", page_path('about') %></li>
<li><%= link_to "Contact", page_path('contact') %></li>
<li><a href="http://news.railstutorial.org/">News</a></li>
<li><a href="http://railstutorial.org/">Rails Tutorial</a></li>
</ul>
Expand Down
6 changes: 6 additions & 0 deletions app/views/static_pages/contact.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<% provide(:title, 'Contact') %>
<h1>Contact</h1>
<p>
Contact Ruby on Rails Tutorial about the sample app at the
<a href="http://railstutorial.org/contact">contact page</a>.
</p>
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
RailsTest::Application.routes.draw do
root :to => 'static_pages#show', :page => 'home'
match 'pages/:page' => 'static_pages#show', :via => :get, :page => /home|about|help/
match ':page' => 'static_pages#show', :via => :get, :page => /home|about|help|contact/, :as => "page"

# The priority is based upon order of creation:
# first created -> highest priority.
Expand Down
25 changes: 19 additions & 6 deletions spec/requests/static_pages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,50 @@

describe "Home page" do
it "should have the content 'Sample App'" do
visit '/static_pages/home'
visit root_path
page.should have_selector('h1', :text=>'Sample App')
end
it "should have the right title" do
visit '/static_pages/home'
visit root_path
page.should have_selector('title',
:text => "#{base_title} | Home")
end
end

describe "Help page" do
it "should have the content 'Help'" do
visit '/static_pages/help'
visit page_path('help')
page.should have_selector('h1', :text=>'Help')
end
it "should have the right title" do
visit '/static_pages/help'
visit page_path('help')
page.should have_selector('title',
:text => "#{base_title} | Help")
end
end

describe "About page" do
it "should have the content 'About'" do
visit '/static_pages/about'
visit page_path('about')
page.should have_selector('h1', :text => 'About')
end
it "should have the right title" do
visit '/static_pages/about'
visit page_path('about')
page.should have_selector('title',
:text => "#{base_title} | About")
end
end

describe "Contact page" do
it "should have the h1 'Contact'" do
visit page_path('contact')
page.should have_selector('h1', text: 'Contact')
end

it "should have the title 'Contact'" do
visit page_path('contact')
page.should have_selector('title',
text: "Ruby on Rails Tutorial Sample App | Contact")
end
end
end

0 comments on commit 3fd18b6

Please sign in to comment.