BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
5b6c1a21
Commit
5b6c1a21
authored
Apr 14, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Issue and ExternalIssue reference specs
parent
b3b8fc6c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
7 deletions
+19
-7
external_issue_reference_filter.rb
lib/gitlab/markdown/external_issue_reference_filter.rb
+4
-0
issue_reference_filter_spec.rb
spec/lib/gitlab/markdown/issue_reference_filter_spec.rb
+15
-7
No files found.
lib/gitlab/markdown/external_issue_reference_filter.rb
View file @
5b6c1a21
module
Gitlab
module
Markdown
# HTML filter that replaces external issue tracker references with links.
# References are ignored if the project doesn't use an external issue
# tracker.
class
ExternalIssueReferenceFilter
<
ReferenceFilter
# Public: Find `JIRA-123` issue references in text
#
...
...
@@ -23,6 +25,8 @@ module Gitlab
ISSUE_PATTERN
=
/(?<issue>([A-Z\-]+-)\d+)/
def
call
return
doc
if
project
.
default_issues_tracker?
replace_text_nodes_matching
(
ISSUE_PATTERN
)
do
|
content
|
issue_link_filter
(
content
)
end
...
...
spec/lib/gitlab/markdown/issue_reference_filter_spec.rb
View file @
5b6c1a21
...
...
@@ -16,13 +16,6 @@ module Gitlab::Markdown
to
raise_error
(
ArgumentError
,
/:project/
)
end
it
'ignores valid references when using non-default tracker'
do
expect
(
project
).
to
receive
(
:default_issues_tracker?
).
and_return
(
false
)
exp
=
act
=
"Issue #
#{
issue
.
iid
}
"
expect
(
filter
(
act
).
to_html
).
to
eq
exp
end
%w(pre code a style)
.
each
do
|
elem
|
it
"ignores valid references contained inside '
#{
elem
}
' element"
do
exp
=
act
=
"<
#{
elem
}
>Issue #
#{
issue
.
iid
}
</
#{
elem
}
>"
...
...
@@ -33,6 +26,13 @@ module Gitlab::Markdown
context
'internal reference'
do
let
(
:reference
)
{
"#
#{
issue
.
iid
}
"
}
it
'ignores valid references when using non-default tracker'
do
expect
(
project
).
to
receive
(
:issue_exists?
).
with
(
issue
.
iid
).
and_return
(
false
)
exp
=
act
=
"Issue #
#{
issue
.
iid
}
"
expect
(
filter
(
act
).
to_html
).
to
eq
exp
end
it
'links to a valid reference'
do
doc
=
filter
(
"See
#{
reference
}
"
)
...
...
@@ -87,6 +87,14 @@ module Gitlab::Markdown
to
receive
(
:user_can_reference_project?
).
and_return
(
true
)
end
it
'ignores valid references when cross-reference project uses external tracker'
do
expect_any_instance_of
(
Project
).
to
receive
(
:issue_exists?
).
with
(
issue
.
iid
).
and_return
(
false
)
exp
=
act
=
"Issue #
#{
issue
.
iid
}
"
expect
(
filter
(
act
).
to_html
).
to
eq
exp
end
it
'links to a valid reference'
do
doc
=
filter
(
"See
#{
reference
}
"
)
...
...
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