Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
5c56a3ba85e3
Commit
5b6c1a21
authored
Apr 14, 2015
by
Robert Speicher
Browse files
Fix Issue and ExternalIssue reference specs
parent
0c26537c9a5d
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/gitlab/markdown/external_issue_reference_filter.rb
View file @
5c56a3ba
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 @@ def self.references_in(text)
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 @
5c56a3ba
...
...
@@ -16,13 +16,6 @@ def helper
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 @@ def helper
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 @@ def helper
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