Skip to content

Commit b2d3dd4

Browse files
author
Ryan Bigg
committed
Section 3.4.4: Add title functionality for show page
1 parent 9279a78 commit b2d3dd4

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
module ApplicationHelper
2+
def title(*parts)
3+
unless parts.empty?
4+
content_for :title do
5+
(parts << "Ticketee").join(" - ")
6+
end
7+
end
8+
end
29
end

ticketee/app/views/layouts/application.html.erb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<title>Ticketee</title>
4+
<title>
5+
<% if content_for?(:title) %>
6+
<%= yield(:title) %>
7+
<% else %>
8+
Ticketee
9+
<% end %>
10+
</title>
511
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
612
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
713
<%= csrf_meta_tags %>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
<% title(@project.name, "Projects") %>
2+
13
<h2><%= @project.name %></h2>

ticketee/spec/features/creating_projects_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,10 @@
88
fill_in 'Description', with: 'A text-editor for all operating systems'
99
click_button 'Create Project'
1010
expect(page).to have_content('Project has been created.')
11+
12+
project = Project.find_by(name: "Sublime Text 3")
13+
expect(page.current_url).to eql(project_url(project))
14+
title = "Sublime Text 3 - Projects - Ticketee"
15+
expect(page).to have_title(title)
1116
end
1217
end

0 commit comments

Comments
 (0)