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
iv
gitlab-ce
Commits
c6d25083
Commit
c6d25083
authored
Dec 24, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Truncate page_description to 30 words
parent
5a3b9c97
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
2 deletions
+15
-2
app/helpers/page_layout_helper.rb
app/helpers/page_layout_helper.rb
+2
-2
spec/helpers/page_layout_helper_spec.rb
spec/helpers/page_layout_helper_spec.rb
+13
-0
No files found.
app/helpers/page_layout_helper.rb
View file @
c6d25083
...
@@ -30,9 +30,9 @@ module PageLayoutHelper
...
@@ -30,9 +30,9 @@ module PageLayoutHelper
@page_description
||=
page_description_default
@page_description
||=
page_description_default
if
description
.
present?
if
description
.
present?
@page_description
=
description
@page_description
=
description
.
squish
else
else
sanitize
(
@page_description
.
squish
,
tags:
[]
)
sanitize
(
@page_description
,
tags:
[]).
truncate_words
(
30
)
end
end
end
end
...
...
spec/helpers/page_layout_helper_spec.rb
View file @
c6d25083
...
@@ -22,6 +22,19 @@ describe PageLayoutHelper do
...
@@ -22,6 +22,19 @@ describe PageLayoutHelper do
expect
(
helper
.
page_description
).
to
eq
'Foo Bar Baz'
expect
(
helper
.
page_description
).
to
eq
'Foo Bar Baz'
end
end
it
'truncates'
do
helper
.
page_description
<<-
LOREM
.
strip_heredoc
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo
ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis
dis parturient montes, nascetur ridiculus mus. Donec quam felis,
ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa
quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget,
arcu.
LOREM
expect
(
helper
.
page_description
).
to
end_with
'quam felis,...'
end
it
'sanitizes all HTML'
do
it
'sanitizes all HTML'
do
helper
.
page_description
(
"<b>Bold</b> <h1>Header</h1>"
)
helper
.
page_description
(
"<b>Bold</b> <h1>Header</h1>"
)
...
...
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