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
b7ed102e
Commit
b7ed102e
authored
Nov 21, 2017
by
Tomasz Maczukin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow filtering by 'status'
parent
8d3e8069
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
5 deletions
+54
-5
lib/api/runners.rb
lib/api/runners.rb
+8
-1
spec/requests/api/runners_spec.rb
spec/requests/api/runners_spec.rb
+46
-4
No files found.
lib/api/runners.rb
View file @
b7ed102e
...
@@ -90,13 +90,20 @@ module API
...
@@ -90,13 +90,20 @@ module API
end
end
params
do
params
do
requires
:id
,
type:
Integer
,
desc:
'The ID of the runner'
requires
:id
,
type:
Integer
,
desc:
'The ID of the runner'
optional
:status
,
type:
String
,
desc:
'Status of job'
use
:pagination
use
:pagination
end
end
get
':id/jobs'
do
get
':id/jobs'
do
runner
=
get_runner
(
params
[
:id
])
runner
=
get_runner
(
params
[
:id
])
authenticate_list_runners_jobs!
(
runner
)
authenticate_list_runners_jobs!
(
runner
)
present
paginate
(
runner
.
builds
.
running
),
with:
Entities
::
JobWithProject
jobs
=
runner
.
builds
if
params
[
:status
]
not_found!
(
'Status'
)
unless
Ci
::
Build
::
AVAILABLE_STATUSES
.
include?
(
params
[
:status
])
jobs
=
jobs
.
where
(
status:
params
[
:status
].
to_sym
)
end
present
paginate
(
jobs
),
with:
Entities
::
JobWithProject
end
end
end
end
...
...
spec/requests/api/runners_spec.rb
View file @
b7ed102e
...
@@ -370,8 +370,8 @@ describe API::Runners do
...
@@ -370,8 +370,8 @@ describe API::Runners do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
).
to
be_an
(
Array
)
expect
(
json_response
[
0
]).
to
include
(
'id'
=>
job_2
.
id
)
expect
(
json_response
.
length
).
to
eq
(
2
)
end
end
end
end
...
@@ -382,8 +382,29 @@ describe API::Runners do
...
@@ -382,8 +382,29 @@ describe API::Runners do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
(
Array
)
expect
(
json_response
.
length
).
to
eq
(
2
)
end
end
context
'when valid status is provided'
do
it
'return filtered jobs'
do
get
api
(
"/runners/
#{
specific_runner
.
id
}
/jobs?status=failed"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
(
Array
)
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
[
0
]).
to
include
(
'id'
=>
job_4
.
id
)
expect
(
json_response
.
first
).
to
include
(
'id'
=>
job_5
.
id
)
end
end
context
'when invalid status is provided'
do
it
'return 404'
do
get
api
(
"/runners/
#{
specific_runner
.
id
}
/jobs?status=non-existing"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
end
end
end
end
end
end
...
@@ -414,8 +435,29 @@ describe API::Runners do
...
@@ -414,8 +435,29 @@ describe API::Runners do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
(
Array
)
expect
(
json_response
.
length
).
to
eq
(
2
)
end
end
context
'when valid status is provided'
do
it
'return filtered jobs'
do
get
api
(
"/runners/
#{
specific_runner
.
id
}
/jobs?status=failed"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
(
Array
)
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
[
0
]).
to
include
(
'id'
=>
job_4
.
id
)
expect
(
json_response
.
first
).
to
include
(
'id'
=>
job_5
.
id
)
end
end
context
'when invalid status is provided'
do
it
'return 404'
do
get
api
(
"/runners/
#{
specific_runner
.
id
}
/jobs?status=non-existing"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
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