Browse files

chapter 4 is nothing

  • Loading branch information...
1 parent 831e8f2 commit 2a19fcbbefae702cf09a5451963b5bfd7de80234 @ajb committed May 17, 2012
View
1 sample_app/.gitignore
@@ -13,3 +13,4 @@
# Ignore all logfiles and tempfiles.
/log/*.log
/tmp
+bundler_stubs
View
8 sample_app/app/helpers/application_helper.rb
@@ -1,2 +1,10 @@
module ApplicationHelper
+ def full_title(page_title)
+ base_title = "Sample App"
+ if page_title.empty?
+ base_title
+ else
+ "#{base_title} | #{page_title}"
+ end
+ end
end
View
2 sample_app/app/views/layouts/application.html.erb
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
- <title>Sample App | <%= yield(:title) %></title>
+ <title><%= full_title(yield(:title)) %></title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
View
1 sample_app/app/views/static_pages/home.html.erb
@@ -1,4 +1,3 @@
-<% provide(:title, 'Home') %>
<h1>Sample App</h1>
<p>
This is the home page for the
View
10 sample_app/spec/requests/static_pages_spec.rb
@@ -7,10 +7,16 @@
page.should have_content('Sample App')
end
- it 'should have the title "Home"' do
+ it 'should have the base title' do
visit '/static_pages/home'
page.should have_selector('title',
- :text => "Sample App | Home")
+ :text => "Sample App")
+ end
+
+ it 'should not have the home page title' do
+ visit '/static_pages/home'
+ page.should_not have_selector('title',
+ :text => "| Home")
end
end

0 comments on commit 2a19fcb

Please sign in to comment.