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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
36e7ffea
Commit
36e7ffea
authored
Feb 05, 2016
by
Tomasz Maczukin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix runners filtering
parent
97c88966
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
4 deletions
+8
-4
lib/api/runners.rb
lib/api/runners.rb
+6
-2
spec/requests/api/runners_spec.rb
spec/requests/api/runners_spec.rb
+2
-2
No files found.
lib/api/runners.rb
View file @
36e7ffea
...
...
@@ -9,7 +9,7 @@ module API
# Example Request:
# GET /runners
get
do
runners
=
filter_runners
(
current_user
.
ci_authorized_runners
,
params
[
:scope
])
runners
=
filter_runners
(
current_user
.
ci_authorized_runners
,
params
[
:scope
]
,
without:
[
'specific'
,
'shared'
]
)
present
paginate
(
runners
),
with:
Entities
::
Runner
end
...
...
@@ -124,10 +124,14 @@ module API
end
helpers
do
def
filter_runners
(
runners
,
scope
)
def
filter_runners
(
runners
,
scope
,
options
=
{}
)
return
runners
unless
scope
.
present?
available_scopes
=
::
Ci
::
Runner
::
AVAILABLE_SCOPES
if
options
[
:without
]
available_scopes
=
available_scopes
-
options
[
:without
]
end
if
(
available_scopes
&
[
scope
]).
empty?
render_api_error!
(
'Scope contains invalid value'
,
400
)
end
...
...
spec/requests/api/runners_spec.rb
View file @
36e7ffea
...
...
@@ -33,7 +33,7 @@ describe API::API, api: true do
end
it
'should filter runners by scope'
do
get
api
(
'/runners?scope=
specific
'
,
user
)
get
api
(
'/runners?scope=
active
'
,
user
)
shared
=
false
||
json_response
.
map
{
|
r
|
r
[
'is_shared'
]
}.
inject
{
|
sum
,
shr
|
sum
||
shr
}
expect
(
response
.
status
).
to
eq
(
200
)
...
...
@@ -78,7 +78,7 @@ describe API::API, api: true do
end
it
'should filter runners by scope'
do
get
api
(
'/runners?scope=specific'
,
admin
)
get
api
(
'/runners
/all
?scope=specific'
,
admin
)
shared
=
false
||
json_response
.
map
{
|
r
|
r
[
'is_shared'
]
}.
inject
{
|
sum
,
shr
|
sum
||
shr
}
expect
(
response
.
status
).
to
eq
(
200
)
...
...
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