Skip to content

Commit fba1ad9

Browse files
author
Ryan Bigg
committed
Section 3.4.4: Add title functionality for show page
1 parent 1f820f8 commit fba1ad9

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
<% title(@project.name, "Projects") %>
12
<h2><%= @project.name %></h2>

ticketee/spec/features/creating_projects_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,12 @@
1111
click_button 'Create Project'
1212

1313
expect(page).to have_content('Project has been created.')
14+
15+
project = Project.where(name: "Sublime Text 3").first
16+
17+
expect(page.current_url).to eql(project_url(project))
18+
19+
title = "Sublime Text 3 - Projects - Ticketee"
20+
expect(page).to have_title(title)
1421
end
1522
end

0 commit comments

Comments
 (0)