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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
af4d16d9
Commit
af4d16d9
authored
Oct 24, 2016
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow the use of params[:name] when filtering labels
parent
7c0ccbaa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
3 deletions
+22
-3
app/finders/labels_finder.rb
app/finders/labels_finder.rb
+10
-3
spec/finders/labels_finder_spec.rb
spec/finders/labels_finder_spec.rb
+12
-0
No files found.
app/finders/labels_finder.rb
View file @
af4d16d9
...
...
@@ -37,10 +37,13 @@ class LabelsFinder < UnionFinder
def
with_title
(
items
)
# Match no labels if an empty title is supplied to avoid matching all
# labels (e.g. when an issue is moved)
return
Label
.
none
if
params
[
:title
]
&&
params
[
:title
]
.
empty?
return
items
.
none
if
raw_title
&&
raw_title
.
empty?
items
=
items
.
where
(
title:
title
)
if
title
items
if
title
items
=
items
.
where
(
title:
title
)
else
items
end
end
def
group_id
...
...
@@ -59,6 +62,10 @@ class LabelsFinder < UnionFinder
params
[
:title
].
presence
||
params
[
:name
].
presence
end
def
raw_title
params
[
:title
]
||
params
[
:name
]
end
def
project
return
@project
if
defined?
(
@project
)
...
...
spec/finders/labels_finder_spec.rb
View file @
af4d16d9
...
...
@@ -65,11 +65,23 @@ describe LabelsFinder do
expect
(
finder
.
execute
).
to
eq
[
group_label_2
]
end
it
'returns label with title alias'
do
finder
=
described_class
.
new
(
user
,
name:
'Group Label 2'
)
expect
(
finder
.
execute
).
to
eq
[
group_label_2
]
end
it
'returns no labels if empty titles are supplied'
do
finder
=
described_class
.
new
(
user
,
title:
[])
expect
(
finder
.
execute
).
to
be_empty
end
it
'returns no labels if empty names are supplied'
do
finder
=
described_class
.
new
(
user
,
name:
[])
expect
(
finder
.
execute
).
to
be_empty
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