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
a6b63f17
Commit
a6b63f17
authored
May 15, 2020
by
Eugenia Grieff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add negated params filter to EpicsFinder
parent
71317bc9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
81 additions
and
10 deletions
+81
-10
ee/app/finders/epics_finder.rb
ee/app/finders/epics_finder.rb
+26
-10
ee/changelogs/unreleased/212579-not-operator-not-functional-when-searching-epics.yml
...2579-not-operator-not-functional-when-searching-epics.yml
+5
-0
ee/spec/finders/epics_finder_spec.rb
ee/spec/finders/epics_finder_spec.rb
+50
-0
No files found.
ee/app/finders/epics_finder.rb
View file @
a6b63f17
...
@@ -55,16 +55,8 @@ class EpicsFinder < IssuableFinder
...
@@ -55,16 +55,8 @@ class EpicsFinder < IssuableFinder
return
Epic
.
none
unless
Ability
.
allowed?
(
current_user
,
:read_epic
,
group
)
return
Epic
.
none
unless
Ability
.
allowed?
(
current_user
,
:read_epic
,
group
)
items
=
init_collection
items
=
init_collection
items
=
by_created_at
(
items
)
items
=
filter_items
(
items
)
items
=
by_updated_at
(
items
)
items
=
filter_negated_items
(
items
)
items
=
by_author
(
items
)
items
=
by_timeframe
(
items
)
items
=
by_state
(
items
)
items
=
by_label
(
items
)
items
=
by_parent
(
items
)
items
=
by_iids
(
items
)
items
=
starts_with_iid
(
items
)
items
=
by_my_reaction_emoji
(
items
)
# This has to be last as we use a CTE as an optimization fence
# This has to be last as we use a CTE as an optimization fence
# for counts by passing the force_cte param and enabling the
# for counts by passing the force_cte param and enabling the
...
@@ -95,6 +87,30 @@ class EpicsFinder < IssuableFinder
...
@@ -95,6 +87,30 @@ class EpicsFinder < IssuableFinder
private
private
def
filter_items
(
items
)
items
=
by_created_at
(
items
)
items
=
by_updated_at
(
items
)
items
=
by_author
(
items
)
items
=
by_timeframe
(
items
)
items
=
by_state
(
items
)
items
=
by_label
(
items
)
items
=
by_parent
(
items
)
items
=
by_iids
(
items
)
items
=
by_my_reaction_emoji
(
items
)
starts_with_iid
(
items
)
end
def
filter_negated_items
(
items
)
return
items
unless
Feature
.
enabled?
(
:not_issuable_queries
,
group
,
default_enabled:
true
)
# API endpoints send in `nil` values so we test if there are any non-nil
return
items
unless
not_params
&
.
values
&
.
any?
items
=
by_negated_label
(
items
)
by_negated_author
(
items
)
end
def
group
def
group
return
unless
params
[
:group_id
]
return
unless
params
[
:group_id
]
return
@group
if
defined?
(
@group
)
return
@group
if
defined?
(
@group
)
...
...
ee/changelogs/unreleased/212579-not-operator-not-functional-when-searching-epics.yml
0 → 100644
View file @
a6b63f17
---
title
:
Add negated params filter to epics search
merge_request
:
32296
author
:
type
:
fixed
ee/spec/finders/epics_finder_spec.rb
View file @
a6b63f17
...
@@ -355,6 +355,56 @@ describe EpicsFinder do
...
@@ -355,6 +355,56 @@ describe EpicsFinder do
end
end
end
end
end
end
context
'with negated labels'
do
let_it_be
(
:label
)
{
create
(
:label
)
}
let_it_be
(
:label2
)
{
create
(
:label
)
}
let_it_be
(
:negated_epic
)
{
create
(
:labeled_epic
,
group:
group
,
labels:
[
label
])
}
let_it_be
(
:negated_epic2
)
{
create
(
:labeled_epic
,
group:
group
,
labels:
[
label2
])
}
let_it_be
(
:params
)
{
{
not:
{
label_name:
[
label
.
title
,
label2
.
title
].
join
(
','
)
}
}
}
it
'returns all epics if no negated labels are present'
do
expect
(
epics
).
to
contain_exactly
(
negated_epic
,
negated_epic2
,
epic1
,
epic2
,
epic3
)
end
it
'returns all epics without negated label'
do
expect
(
epics
(
params
)).
to
contain_exactly
(
epic1
,
epic2
,
epic3
)
end
context
'when not_issuable_queries is disabled'
do
before
do
stub_feature_flags
(
not_issuable_queries:
false
)
end
it
'returns epics that include negated params'
do
expect
(
epics
(
params
)).
to
contain_exactly
(
negated_epic
,
negated_epic2
,
epic1
,
epic2
,
epic3
)
end
end
end
context
'with negated author'
do
let_it_be
(
:author
)
{
create
(
:user
)
}
let_it_be
(
:authored_epic
)
{
create
(
:epic
,
group:
group
,
author:
author
)
}
let_it_be
(
:params
)
{
{
not:
{
author_id:
author
.
id
}
}
}
it
'returns all epics if no negated author is present'
do
expect
(
epics
).
to
contain_exactly
(
authored_epic
,
epic1
,
epic2
,
epic3
)
end
it
'returns all epics without given author'
do
expect
(
epics
(
params
)).
to
contain_exactly
(
epic1
,
epic2
,
epic3
)
end
context
'when not_issuable_queries is disabled'
do
before
do
stub_feature_flags
(
not_issuable_queries:
false
)
end
it
'returns epics that include negated params'
do
expect
(
epics
(
params
)).
to
contain_exactly
(
authored_epic
,
epic1
,
epic2
,
epic3
)
end
end
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