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
Kazuhiko Shiozaki
gitlab-ce
Commits
86f706b1
Commit
86f706b1
authored
Sep 01, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix GitlabMarkdownHelper spec
parent
81fc63be
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
11 deletions
+14
-11
spec/helpers/gitlab_markdown_helper_spec.rb
spec/helpers/gitlab_markdown_helper_spec.rb
+14
-11
No files found.
spec/helpers/gitlab_markdown_helper_spec.rb
View file @
86f706b1
...
@@ -11,12 +11,15 @@ describe GitlabMarkdownHelper do
...
@@ -11,12 +11,15 @@ describe GitlabMarkdownHelper do
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
target_project:
project
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
target_project:
project
)
}
let
(
:snippet
)
{
create
(
:project_snippet
,
project:
project
)
}
let
(
:snippet
)
{
create
(
:project_snippet
,
project:
project
)
}
# Helper expects a current_user method.
let
(
:current_user
)
{
user
}
before
do
before
do
# Ensure the generated reference links aren't redacted
project
.
team
<<
[
user
,
:master
]
# Helper expects a @project instance variable
# Helper expects a @project instance variable
@project
=
project
helper
.
instance_variable_set
(
:@project
,
project
)
# Stub the `current_user` helper
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
user
)
end
end
describe
"#markdown"
do
describe
"#markdown"
do
...
@@ -25,17 +28,17 @@ describe GitlabMarkdownHelper do
...
@@ -25,17 +28,17 @@ describe GitlabMarkdownHelper do
it
"should link to the merge request"
do
it
"should link to the merge request"
do
expected
=
namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
)
expected
=
namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request
)
expect
(
markdown
(
actual
)).
to
match
(
expected
)
expect
(
helper
.
markdown
(
actual
)).
to
match
(
expected
)
end
end
it
"should link to the commit"
do
it
"should link to the commit"
do
expected
=
namespace_project_commit_path
(
project
.
namespace
,
project
,
commit
)
expected
=
namespace_project_commit_path
(
project
.
namespace
,
project
,
commit
)
expect
(
markdown
(
actual
)).
to
match
(
expected
)
expect
(
helper
.
markdown
(
actual
)).
to
match
(
expected
)
end
end
it
"should link to the issue"
do
it
"should link to the issue"
do
expected
=
namespace_project_issue_path
(
project
.
namespace
,
project
,
issue
)
expected
=
namespace_project_issue_path
(
project
.
namespace
,
project
,
issue
)
expect
(
markdown
(
actual
)).
to
match
(
expected
)
expect
(
helper
.
markdown
(
actual
)).
to
match
(
expected
)
end
end
end
end
end
end
...
@@ -45,7 +48,7 @@ describe GitlabMarkdownHelper do
...
@@ -45,7 +48,7 @@ describe GitlabMarkdownHelper do
let
(
:issues
)
{
create_list
(
:issue
,
2
,
project:
project
)
}
let
(
:issues
)
{
create_list
(
:issue
,
2
,
project:
project
)
}
it
'should handle references nested in links with all the text'
do
it
'should handle references nested in links with all the text'
do
actual
=
link_to_gfm
(
"This should finally fix
#{
issues
[
0
].
to_reference
}
and
#{
issues
[
1
].
to_reference
}
for real"
,
commit_path
)
actual
=
helper
.
link_to_gfm
(
"This should finally fix
#{
issues
[
0
].
to_reference
}
and
#{
issues
[
1
].
to_reference
}
for real"
,
commit_path
)
doc
=
Nokogiri
::
HTML
.
parse
(
actual
)
doc
=
Nokogiri
::
HTML
.
parse
(
actual
)
# Make sure we didn't create invalid markup
# Make sure we didn't create invalid markup
...
@@ -75,7 +78,7 @@ describe GitlabMarkdownHelper do
...
@@ -75,7 +78,7 @@ describe GitlabMarkdownHelper do
end
end
it
'should forward HTML options'
do
it
'should forward HTML options'
do
actual
=
link_to_gfm
(
"Fixed in
#{
commit
.
id
}
"
,
commit_path
,
class:
'foo'
)
actual
=
helper
.
link_to_gfm
(
"Fixed in
#{
commit
.
id
}
"
,
commit_path
,
class:
'foo'
)
doc
=
Nokogiri
::
HTML
.
parse
(
actual
)
doc
=
Nokogiri
::
HTML
.
parse
(
actual
)
expect
(
doc
.
css
(
'a'
)).
to
satisfy
do
|
v
|
expect
(
doc
.
css
(
'a'
)).
to
satisfy
do
|
v
|
...
@@ -86,13 +89,13 @@ describe GitlabMarkdownHelper do
...
@@ -86,13 +89,13 @@ describe GitlabMarkdownHelper do
it
"escapes HTML passed in as the body"
do
it
"escapes HTML passed in as the body"
do
actual
=
"This is a <h1>test</h1> - see
#{
issues
[
0
].
to_reference
}
"
actual
=
"This is a <h1>test</h1> - see
#{
issues
[
0
].
to_reference
}
"
expect
(
link_to_gfm
(
actual
,
commit_path
)).
expect
(
helper
.
link_to_gfm
(
actual
,
commit_path
)).
to
match
(
'<h1>test</h1>'
)
to
match
(
'<h1>test</h1>'
)
end
end
it
'ignores reference links when they are the entire body'
do
it
'ignores reference links when they are the entire body'
do
text
=
issues
[
0
].
to_reference
text
=
issues
[
0
].
to_reference
act
=
link_to_gfm
(
text
,
'/foo'
)
act
=
helper
.
link_to_gfm
(
text
,
'/foo'
)
expect
(
act
).
to
eq
%Q(<a href="/foo">
#{
issues
[
0
].
to_reference
}
</a>)
expect
(
act
).
to
eq
%Q(<a href="/foo">
#{
issues
[
0
].
to_reference
}
</a>)
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