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
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
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
7 deletions
+19
-7
lib/gitlab/markdown/external_issue_reference_filter.rb
lib/gitlab/markdown/external_issue_reference_filter.rb
+4
-0
spec/lib/gitlab/markdown/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
Gitlab
module
Markdown
module
Markdown
# HTML filter that replaces external issue tracker references with links.
# 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
class
ExternalIssueReferenceFilter
<
ReferenceFilter
# Public: Find `JIRA-123` issue references in text
# Public: Find `JIRA-123` issue references in text
#
#
...
@@ -23,6 +25,8 @@ module Gitlab
...
@@ -23,6 +25,8 @@ module Gitlab
ISSUE_PATTERN
=
/(?<issue>([A-Z\-]+-)\d+)/
ISSUE_PATTERN
=
/(?<issue>([A-Z\-]+-)\d+)/
def
call
def
call
return
doc
if
project
.
default_issues_tracker?
replace_text_nodes_matching
(
ISSUE_PATTERN
)
do
|
content
|
replace_text_nodes_matching
(
ISSUE_PATTERN
)
do
|
content
|
issue_link_filter
(
content
)
issue_link_filter
(
content
)
end
end
...
...
spec/lib/gitlab/markdown/issue_reference_filter_spec.rb
View file @
5b6c1a21
...
@@ -16,13 +16,6 @@ module Gitlab::Markdown
...
@@ -16,13 +16,6 @@ module Gitlab::Markdown
to
raise_error
(
ArgumentError
,
/:project/
)
to
raise_error
(
ArgumentError
,
/:project/
)
end
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
|
%w(pre code a style)
.
each
do
|
elem
|
it
"ignores valid references contained inside '
#{
elem
}
' element"
do
it
"ignores valid references contained inside '
#{
elem
}
' element"
do
exp
=
act
=
"<
#{
elem
}
>Issue #
#{
issue
.
iid
}
</
#{
elem
}
>"
exp
=
act
=
"<
#{
elem
}
>Issue #
#{
issue
.
iid
}
</
#{
elem
}
>"
...
@@ -33,6 +26,13 @@ module Gitlab::Markdown
...
@@ -33,6 +26,13 @@ module Gitlab::Markdown
context
'internal reference'
do
context
'internal reference'
do
let
(
:reference
)
{
"#
#{
issue
.
iid
}
"
}
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
it
'links to a valid reference'
do
doc
=
filter
(
"See
#{
reference
}
"
)
doc
=
filter
(
"See
#{
reference
}
"
)
...
@@ -87,6 +87,14 @@ module Gitlab::Markdown
...
@@ -87,6 +87,14 @@ module Gitlab::Markdown
to
receive
(
:user_can_reference_project?
).
and_return
(
true
)
to
receive
(
:user_can_reference_project?
).
and_return
(
true
)
end
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
it
'links to a valid reference'
do
doc
=
filter
(
"See
#{
reference
}
"
)
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