Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
rails-tutorials
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tô Ngọc Ánh
rails-tutorials
Commits
6ed39041
Commit
6ed39041
authored
Jun 24, 2020
by
Tô Ngọc Ánh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a full_title helper
parent
cf6c3f40
Pipeline
#655
failed with stages
in 0 seconds
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
3 deletions
+16
-3
sample_app/app/helpers/application_helper.rb
+9
-0
sample_app/app/views/layouts/application.html.erb
+1
-1
sample_app/app/views/static_pages/home.html.erb
+0
-1
sample_app/spec/requests/static_pages_spec.rb
+6
-1
No files found.
sample_app/app/helpers/application_helper.rb
View file @
6ed39041
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
sample_app/app/views/layouts/application.html.erb
View file @
6ed39041
...
...
@@ -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
%>
...
...
sample_app/app/views/static_pages/home.html.erb
View file @
6ed39041
<%
provide
(
:title
,
'Home'
)
%>
<h1>
Sample App
</h1>
<p>
This is the home page for the
...
...
sample_app/spec/requests/static_pages_spec.rb
View file @
6ed39041
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment