Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
43053c2e
Commit
43053c2e
authored
Jan 05, 2016
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make `page_description` less magical
✨
parent
a298f694
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
42 deletions
+11
-42
app/helpers/page_layout_helper.rb
app/helpers/page_layout_helper.rb
+1
-11
app/views/layouts/group.html.haml
app/views/layouts/group.html.haml
+4
-3
app/views/layouts/project.html.haml
app/views/layouts/project.html.haml
+4
-3
spec/helpers/page_layout_helper_spec.rb
spec/helpers/page_layout_helper_spec.rb
+2
-25
No files found.
app/helpers/page_layout_helper.rb
View file @
43053c2e
...
...
@@ -27,7 +27,7 @@ module PageLayoutHelper
#
# Returns an HTML-safe String.
def
page_description
(
description
=
nil
)
@page_description
||=
page_description_default
@page_description
||=
brand_title
if
description
.
present?
@page_description
=
description
.
squish
...
...
@@ -36,16 +36,6 @@ module PageLayoutHelper
end
end
# Default value for page_description when one hasn't been defined manually by
# a view
def
page_description_default
if
@project
@project
.
description
||
brand_title
else
brand_title
end
end
def
page_image
default
=
image_url
(
'gitlab_logo.png'
)
...
...
app/views/layouts/group.html.haml
View file @
43053c2e
-
page_title
@group
.
name
-
page_description
@group
.
description
-
header_title
group_title
(
@group
)
unless
header_title
-
sidebar
"group"
unless
sidebar
...
...
app/views/layouts/project.html.haml
View file @
43053c2e
-
page_title
@project
.
name_with_namespace
-
page_description
@project
.
description
-
header_title
project_title
(
@project
)
unless
header_title
-
sidebar
"project"
unless
sidebar
...
...
spec/helpers/page_layout_helper_spec.rb
View file @
43053c2e
...
...
@@ -2,8 +2,8 @@ require 'rails_helper'
describe
PageLayoutHelper
do
describe
'page_description'
do
it
'defaults to value returned by
page_description_default
helper'
do
allow
(
helper
).
to
receive
(
:
page_description_default
).
and_return
(
'Foo'
)
it
'defaults to value returned by
brand_title
helper'
do
allow
(
helper
).
to
receive
(
:
brand_title
).
and_return
(
'Foo'
)
expect
(
helper
.
page_description
).
to
eq
'Foo'
end
...
...
@@ -42,29 +42,6 @@ describe PageLayoutHelper do
end
end
describe
'page_description_default'
do
it
'uses Project description when available'
do
project
=
double
(
description:
'Project Description'
)
assign
(
:project
,
project
)
expect
(
helper
.
page_description_default
).
to
eq
'Project Description'
end
it
'uses brand_title when Project description is nil'
do
project
=
double
(
description:
nil
)
assign
(
:project
,
project
)
expect
(
helper
).
to
receive
(
:brand_title
).
and_return
(
'Brand Title'
)
expect
(
helper
.
page_description_default
).
to
eq
'Brand Title'
end
it
'falls back to brand_title'
do
allow
(
helper
).
to
receive
(
:brand_title
).
and_return
(
'Brand Title'
)
expect
(
helper
.
page_description_default
).
to
eq
'Brand Title'
end
end
describe
'page_image'
do
it
'defaults to the GitLab logo'
do
expect
(
helper
.
page_image
).
to
end_with
'assets/gitlab_logo.png'
...
...
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