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
f7348cd3
Commit
f7348cd3
authored
Apr 19, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix cross-project label ref with invalid project
Closes #15168
parent
2ade37e2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
17 deletions
+27
-17
lib/banzai/filter/label_reference_filter.rb
lib/banzai/filter/label_reference_filter.rb
+1
-1
spec/lib/banzai/filter/label_reference_filter_spec.rb
spec/lib/banzai/filter/label_reference_filter_spec.rb
+26
-16
No files found.
lib/banzai/filter/label_reference_filter.rb
View file @
f7348cd3
...
@@ -20,7 +20,7 @@ module Banzai
...
@@ -20,7 +20,7 @@ module Banzai
text
.
gsub
(
pattern
)
do
|
match
|
text
.
gsub
(
pattern
)
do
|
match
|
project
=
project_from_ref
(
$~
[
:project
])
project
=
project_from_ref
(
$~
[
:project
])
params
=
label_params
(
$~
[
:label_id
].
to_i
,
$~
[
:label_name
])
params
=
label_params
(
$~
[
:label_id
].
to_i
,
$~
[
:label_name
])
label
=
project
.
labels
.
find_by
(
params
)
label
=
project
.
labels
.
find_by
(
params
)
if
project
if
label
if
label
yield
match
,
label
.
id
,
$~
[
:project
],
$~
yield
match
,
label
.
id
,
$~
[
:project
],
$~
...
...
spec/lib/banzai/filter/label_reference_filter_spec.rb
View file @
f7348cd3
...
@@ -178,27 +178,37 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do
...
@@ -178,27 +178,37 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do
end
end
describe
'cross project label references'
do
describe
'cross project label references'
do
let
(
:another_project
)
{
create
(
:empty_project
,
:public
)
}
context
'valid project referenced'
do
let
(
:project_name
)
{
another_project
.
name_with_namespace
}
let
(
:another_project
)
{
create
(
:empty_project
,
:public
)
}
let
(
:label
)
{
create
(
:label
,
project:
another_project
,
color:
'#00ff00'
)
}
let
(
:project_name
)
{
another_project
.
name_with_namespace
}
let
(
:reference
)
{
label
.
to_reference
(
project
)
}
let
(
:label
)
{
create
(
:label
,
project:
another_project
,
color:
'#00ff00'
)
}
let
(
:reference
)
{
label
.
to_reference
(
project
)
}
let!
(
:result
)
{
reference_filter
(
"See
#{
reference
}
"
)
}
let!
(
:result
)
{
reference_filter
(
"See
#{
reference
}
"
)
}
it
'points to referenced project issues page'
do
it
'points to referenced project issues page'
do
expect
(
result
.
css
(
'a'
).
first
.
attr
(
'href'
))
expect
(
result
.
css
(
'a'
).
first
.
attr
(
'href'
))
.
to
eq
urls
.
namespace_project_issues_url
(
another_project
.
namespace
,
.
to
eq
urls
.
namespace_project_issues_url
(
another_project
.
namespace
,
another_project
,
another_project
,
label_name:
label
.
name
)
label_name:
label
.
name
)
end
end
it
'has valid color'
do
expect
(
result
.
css
(
'a span'
).
first
.
attr
(
'style'
))
.
to
match
/background-color: #00ff00/
end
it
'has valid color
'
do
it
'contains cross project content
'
do
expect
(
result
.
css
(
'a span'
).
first
.
attr
(
'style'
))
expect
(
result
.
css
(
'a'
).
first
.
text
).
to
eq
"
#{
label
.
name
}
in
#{
project_name
}
"
.
to
match
/background-color: #00ff00/
end
end
end
it
'contains cross project content'
do
context
'project that does not exist referenced'
do
expect
(
result
.
css
(
'a'
).
first
.
text
).
to
eq
"
#{
label
.
name
}
in
#{
project_name
}
"
let
(
:result
)
{
reference_filter
(
'aaa/bbb~ccc'
)
}
it
'does not link reference'
do
expect
(
result
.
to_html
).
to
eq
'aaa/bbb~ccc'
end
end
end
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