Commit 8bac2010 by Tô Ngọc Ánh

Merge branch 'chapter-4' into 'master'

Chapter 4

See merge request !2
parents 87a2b690 6ed39041
Pipeline #677 failed with stages
in 0 seconds
module ApplicationHelper
# Returns the full title on a per-page basis.
def full_title(page_title)
base_title = "Ruby on Rails Tutorial Sample App"
if page_title.empty?
base_title
else
"#{base_title} | #{page_title}"
end
end
end
......@@ -2,7 +2,7 @@
<html>
<head>
<title>Ruby on Rails Tutorial Sample App | <%= yield(:title) %></title>
<title><%= full_title(yield(:title)) %></title>
<title>SampleApp</title>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
......
<% provide(:title, 'Home') %>
<h1>Sample App</h1>
<p>
This is the home page for the
......
......@@ -22,7 +22,12 @@ describe "Static pages" do
it "should have the right title" do
visit '/static_pages/home'
expect(page).to have_title("#{base_title} | Home")
expect(page).to have_title("#{base_title}")
end
it "should not have a custom page title" do
visit '/static_pages/home'
expect(page).not_to have_title('| Home')
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment