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
02aad721
Commit
02aad721
authored
Feb 16, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only yield valid references in ReferenceFilter.references_in
parent
a2801ec4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
2 deletions
+33
-2
changelogs/unreleased/only-yield-valid-reference-matches.yml
changelogs/unreleased/only-yield-valid-reference-matches.yml
+4
-0
lib/banzai/filter/abstract_reference_filter.rb
lib/banzai/filter/abstract_reference_filter.rb
+6
-1
spec/lib/banzai/filter/issue_reference_filter_spec.rb
spec/lib/banzai/filter/issue_reference_filter_spec.rb
+23
-1
No files found.
changelogs/unreleased/only-yield-valid-reference-matches.yml
0 → 100644
View file @
02aad721
---
title
:
Only yield valid references in ReferenceFilter.references_in
merge_request
:
author
:
lib/banzai/filter/abstract_reference_filter.rb
View file @
02aad721
...
...
@@ -33,7 +33,12 @@ module Banzai
# Returns a String replaced with the return of the block.
def
self
.
references_in
(
text
,
pattern
=
object_class
.
reference_pattern
)
text
.
gsub
(
pattern
)
do
|
match
|
yield
match
,
$~
[
object_sym
].
to_i
,
$~
[
:project
],
$~
[
:namespace
],
$~
symbol
=
$~
[
object_sym
]
if
object_class
.
reference_valid?
(
symbol
)
yield
match
,
symbol
.
to_i
,
$~
[
:project
],
$~
[
:namespace
],
$~
else
match
end
end
end
...
...
spec/lib/banzai/filter/issue_reference_filter_spec.rb
View file @
02aad721
...
...
@@ -311,7 +311,7 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do
end
end
describe
'#issues_per_
P
roject'
do
describe
'#issues_per_
p
roject'
do
context
'using an internal issue tracker'
do
it
'returns a Hash containing the issues per project'
do
doc
=
Nokogiri
::
HTML
.
fragment
(
''
)
...
...
@@ -346,4 +346,26 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do
end
end
end
describe
'.references_in'
do
let
(
:merge_request
)
{
create
(
:merge_request
)
}
it
'yields valid references'
do
expect
do
|
b
|
described_class
.
references_in
(
issue
.
to_reference
,
&
b
)
end
.
to
yield_with_args
(
issue
.
to_reference
,
issue
.
iid
,
nil
,
nil
,
MatchData
)
end
it
"doesn't yield invalid references"
do
expect
do
|
b
|
described_class
.
references_in
(
'#0'
,
&
b
)
end
.
not_to
yield_control
end
it
"doesn't yield unsupported references"
do
expect
do
|
b
|
described_class
.
references_in
(
merge_request
.
to_reference
,
&
b
)
end
.
not_to
yield_control
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