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
Léo-Paul Géneau
gitlab-ce
Commits
e0f0c29b
Commit
e0f0c29b
authored
Oct 26, 2018
by
Heinrich Lee Yu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support lowercase none / any
parent
bf1ed85a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
9 deletions
+21
-9
app/finders/issuable_finder.rb
app/finders/issuable_finder.rb
+4
-4
lib/api/helpers/custom_validators.rb
lib/api/helpers/custom_validators.rb
+1
-1
spec/finders/issues_finder_spec.rb
spec/finders/issues_finder_spec.rb
+14
-4
spec/lib/api/helpers/custom_validators_spec.rb
spec/lib/api/helpers/custom_validators_spec.rb
+2
-0
No files found.
app/finders/issuable_finder.rb
View file @
e0f0c29b
...
...
@@ -35,8 +35,8 @@ class IssuableFinder
requires_cross_project_access
unless:
->
{
project?
}
# This is used as a common filter for None / Any
FILTER_NONE
=
'
N
one'
.
freeze
FILTER_ANY
=
'
A
ny'
.
freeze
FILTER_NONE
=
'
n
one'
.
freeze
FILTER_ANY
=
'
a
ny'
.
freeze
# This is accepted as a deprecated filter and is also used in unassigning users
NONE
=
'0'
.
freeze
...
...
@@ -250,11 +250,11 @@ class IssuableFinder
def
filter_by_no_assignee?
# Assignee_id takes precedence over assignee_username
[
NONE
,
FILTER_NONE
].
include?
(
params
[
:assignee_id
].
to_s
)
||
params
[
:assignee_username
].
to_s
==
NONE
[
NONE
,
FILTER_NONE
].
include?
(
params
[
:assignee_id
].
to_s
.
downcase
)
||
params
[
:assignee_username
].
to_s
==
NONE
end
def
filter_by_any_assignee?
params
[
:assignee_id
].
to_s
==
FILTER_ANY
params
[
:assignee_id
].
to_s
.
downcase
==
FILTER_ANY
end
# rubocop: disable CodeReuse/ActiveRecord
...
...
lib/api/helpers/custom_validators.rb
View file @
e0f0c29b
...
...
@@ -16,7 +16,7 @@ module API
value
=
params
[
attr_name
]
return
if
value
.
is_a?
(
Integer
)
||
[
IssuableFinder
::
FILTER_NONE
,
IssuableFinder
::
FILTER_ANY
].
include?
(
value
)
[
IssuableFinder
::
FILTER_NONE
,
IssuableFinder
::
FILTER_ANY
].
include?
(
value
.
to_s
.
downcase
)
raise
Grape
::
Exceptions
::
Validation
,
params:
[
@scope
.
full_name
(
attr_name
)],
message:
"should be an integer, 'None' or 'Any'"
...
...
spec/finders/issues_finder_spec.rb
View file @
e0f0c29b
...
...
@@ -57,17 +57,21 @@ describe IssuesFinder do
end
context
'filtering by no assignee'
do
let
(
:params
)
{
{
assignee_id:
0
}
}
let
(
:params
)
{
{
assignee_id:
'None'
}
}
it
'returns issues not assigned to any assignee'
do
expect
(
issues
).
to
contain_exactly
(
issue4
)
end
end
context
'filtering by no assignee'
do
let
(
:params
)
{
{
assignee_id:
'None'
}
}
it
'returns issues not assigned to any assignee'
do
params
[
:assignee_id
]
=
0
expect
(
issues
).
to
contain_exactly
(
issue4
)
end
it
'returns issues not assigned to any assignee'
do
params
[
:assignee_id
]
=
'none'
expect
(
issues
).
to
contain_exactly
(
issue4
)
end
end
...
...
@@ -78,6 +82,12 @@ describe IssuesFinder do
it
'returns issues assigned to any assignee'
do
expect
(
issues
).
to
contain_exactly
(
issue1
,
issue2
,
issue3
)
end
it
'returns issues assigned to any assignee'
do
params
[
:assignee_id
]
=
'any'
expect
(
issues
).
to
contain_exactly
(
issue1
,
issue2
,
issue3
)
end
end
context
'filtering by group_id'
do
...
...
spec/lib/api/helpers/custom_validators_spec.rb
View file @
e0f0c29b
...
...
@@ -38,6 +38,8 @@ describe API::Helpers::CustomValidators do
expect_no_validation_error
({
'test'
=>
100
})
expect_no_validation_error
({
'test'
=>
'None'
})
expect_no_validation_error
({
'test'
=>
'Any'
})
expect_no_validation_error
({
'test'
=>
'none'
})
expect_no_validation_error
({
'test'
=>
'any'
})
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