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
Jérome Perrin
gitlab-ce
Commits
05bbad58
Commit
05bbad58
authored
May 11, 2016
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up EventsHelper spec
parent
459af7ff
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
47 deletions
+48
-47
spec/helpers/events_helper_spec.rb
spec/helpers/events_helper_spec.rb
+48
-47
No files found.
spec/helpers/events_helper_spec.rb
View file @
05bbad58
require
'spec_helper'
require
'spec_helper'
describe
EventsHelper
do
describe
EventsHelper
do
include
ApplicationHelper
describe
'#event_note'
do
include
GitlabMarkdownHelper
before
do
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
double
)
let
(
:current_user
)
{
create
(
:user
,
email:
"current@email.com"
)
}
end
it
'should display one line of plain text without alteration'
do
it
'should display one line of plain text without alteration'
do
input
=
'A short, plain note'
input
=
'A short, plain note'
expect
(
event_note
(
input
)).
to
match
(
input
)
expect
(
helper
.
event_note
(
input
)).
to
match
(
input
)
expect
(
event_note
(
input
)).
not_to
match
(
/\.\.\.\z/
)
expect
(
helper
.
event_note
(
input
)).
not_to
match
(
/\.\.\.\z/
)
end
end
it
'should display inline code'
do
it
'should display inline code'
do
input
=
'A note with `inline code`'
input
=
'A note with `inline code`'
expected
=
'A note with <code>inline code</code>'
expected
=
'A note with <code>inline code</code>'
expect
(
event_note
(
input
)).
to
match
(
expected
)
expect
(
helper
.
event_note
(
input
)).
to
match
(
expected
)
end
end
it
'should truncate a note with multiple paragraphs'
do
it
'should truncate a note with multiple paragraphs'
do
input
=
"Paragraph 1
\n\n
Paragraph 2"
input
=
"Paragraph 1
\n\n
Paragraph 2"
expected
=
'Paragraph 1...'
expected
=
'Paragraph 1...'
expect
(
event_note
(
input
)).
to
match
(
expected
)
expect
(
helper
.
event_note
(
input
)).
to
match
(
expected
)
end
end
it
'should display the first line of a code block'
do
it
'should display the first line of a code block'
do
input
=
"```
\n
Code block
\n
with two lines
\n
```"
input
=
"```
\n
Code block
\n
with two lines
\n
```"
expected
=
%r{<pre.+><code>Code block
\.\.\.
</code></pre>}
expected
=
%r{<pre.+><code>Code block
\.\.\.
</code></pre>}
expect
(
event_note
(
input
)).
to
match
(
expected
)
expect
(
helper
.
event_note
(
input
)).
to
match
(
expected
)
end
end
it
'should truncate a single long line of text'
do
it
'should truncate a single long line of text'
do
text
=
'The quick brown fox jumped over the lazy dog twice'
# 50 chars
text
=
'The quick brown fox jumped over the lazy dog twice'
# 50 chars
input
=
"
#{
text
}#{
text
}#{
text
}#{
text
}
"
# 200 chars
input
=
text
*
4
expected
=
"
#{
text
}#{
text
}
"
.
sub
(
/.{3}/
,
'...'
)
expected
=
(
text
*
2
)
.
sub
(
/.{3}/
,
'...'
)
expect
(
event_note
(
input
)).
to
match
(
expected
)
expect
(
helper
.
event_note
(
input
)).
to
match
(
expected
)
end
end
it
'should preserve a link href when link text is truncated'
do
it
'should preserve a link href when link text is truncated'
do
...
@@ -48,8 +48,8 @@ describe EventsHelper do
...
@@ -48,8 +48,8 @@ describe EventsHelper do
input
<<
link_url
input
<<
link_url
expected_link_text
=
'http://example...</a>'
expected_link_text
=
'http://example...</a>'
expect
(
event_note
(
input
)).
to
match
(
link_url
)
expect
(
helper
.
event_note
(
input
)).
to
match
(
link_url
)
expect
(
event_note
(
input
)).
to
match
(
expected_link_text
)
expect
(
helper
.
event_note
(
input
)).
to
match
(
expected_link_text
)
end
end
it
'should preserve code color scheme'
do
it
'should preserve code color scheme'
do
...
@@ -59,6 +59,7 @@ describe EventsHelper do
...
@@ -59,6 +59,7 @@ describe EventsHelper do
" <span class=
\"
s1
\"
>
\'
hello world
\'
</span>
\n
"
\
" <span class=
\"
s1
\"
>
\'
hello world
\'
</span>
\n
"
\
"<span class=
\"
k
\"
>end</span>"
\
"<span class=
\"
k
\"
>end</span>"
\
'</code></pre>'
'</code></pre>'
expect
(
event_note
(
input
)).
to
eq
(
expected
)
expect
(
helper
.
event_note
(
input
)).
to
eq
(
expected
)
end
end
end
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