Skip to content

Commit

Permalink
Named routes added
Browse files Browse the repository at this point in the history
  • Loading branch information
safalmj committed Aug 26, 2012
1 parent cd9ab60 commit 46530be
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions app/views/layouts/_footer.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
</small>
<nav>
<ul>
<li><%= link_to "About", '#' %></li>
<li><%= link_to "Contact", '#' %></li>
<li><%= link_to "About", about_path %></li>
<li><%= link_to "Contact", contact_path %></li>
<li><a href="http://news.railstutorial.org/">News</a></li>
</ul>
</nav>
Expand Down
6 changes: 3 additions & 3 deletions app/views/layouts/_header.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<header class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<%= link_to "sample app", '#', :id => "logo" %>
<%= link_to "sample app", root_path, :id => "logo" %>
<nav>
<ul class="nav pull-right">
<li><%= link_to "Home", '#' %></li>
<li><%= link_to "Help", '#' %></li>
<li><%= link_to "Home", root_path %></li>
<li><%= link_to "Help", help_path %></li>
<li><%= link_to "Sign in", '#' %></li>
</ul>
</nav>
Expand Down
10 changes: 5 additions & 5 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
SampleApp::Application.routes.draw do
root :to => "staticPages#home"
get "static_pages/home"
get "static_pages/help"
get "/static_pages/about"
get "/static_pages/contact"
root :to => "static_pages#home"

match "/help", :to => "static_pages#help"
match "/about", :to => "static_pages#about"
match "/contact", :to => "static_pages#contact"

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

describe "Home page" do
it "should have the h1 'Sample App'" do
visit '/static_pages/home'
visit root_path
#page.should have_content('Sample App')
page.should have_selector('h1',
:text => 'Sample App')
end

it "should have the title 'Home'" 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 h1 'Help'" do
visit '/static_pages/help'
visit help_path
page.should have_selector('h1',
:text => 'Help')
end

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

describe "About Us" do
it "should have the h1 'About us'" do
visit "/static_pages/about"
visit about_path
page.should have_selector('h1',
:text => "About")
end

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

describe "Contact Page" do
it "should have the h1 'Contact'" do
visit "/static_pages/contact"
visit contact_path
page.should have_selector('h1',
:text => "Contact")
end

it "should have the title 'Contact'" do
visit "/static_pages/contact"
visit contact_path
page.should have_selector('title',
:text => "#{base_title} | Contact")
end
Expand Down

0 comments on commit 46530be

Please sign in to comment.