BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
b7ed102e
Unverified
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
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
5 deletions
+54
-5
runners.rb
lib/api/runners.rb
+8
-1
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
end
params
do
requires
:id
,
type:
Integer
,
desc:
'The ID of the runner'
optional
:status
,
type:
String
,
desc:
'Status of job'
use
:pagination
end
get
':id/jobs'
do
runner
=
get_runner
(
params
[
:id
])
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
...
...
spec/requests/api/runners_spec.rb
View file @
b7ed102e
...
...
@@ -370,8 +370,8 @@ describe API::Runners do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
[
0
]).
to
include
(
'id'
=>
job_2
.
id
)
expect
(
json_response
).
to
be_an
(
Array
)
expect
(
json_response
.
length
).
to
eq
(
2
)
end
end
...
...
@@ -382,8 +382,29 @@ describe API::Runners do
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
(
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
[
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
...
...
@@ -414,8 +435,29 @@ describe API::Runners do
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
(
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
[
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
...
...
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