Commit 8cc61d0b authored by Rémy Coutable's avatar Rémy Coutable
Browse files

Merge branch '26875-builds-api-endpoint-skipped-scope' into 'master'

Add all available statuses to scope filter for project builds endpoint

Closes #26875

See merge request !8971
---
title: Add all available statuses to scope filter for project builds endpoint
merge_request:
author: George Andrinopoulos
...@@ -11,7 +11,7 @@ class Builds < Grape::API ...@@ -11,7 +11,7 @@ class Builds < Grape::API
helpers do helpers do
params :optional_scope do params :optional_scope do
optional :scope, types: [String, Array[String]], desc: 'The scope of builds to show', optional :scope, types: [String, Array[String]], desc: 'The scope of builds to show',
values: ['pending', 'running', 'failed', 'success', 'canceled'], values: ::CommitStatus::AVAILABLE_STATUSES,
coerce_with: ->(scope) { coerce_with: ->(scope) {
if scope.is_a?(String) if scope.is_a?(String)
[scope] [scope]
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
let(:query) { '' } let(:query) { '' }
before do before do
create(:ci_build, :skipped, pipeline: pipeline)
get api("/projects/#{project.id}/builds?#{query}", api_user) get api("/projects/#{project.id}/builds?#{query}", api_user)
end end
...@@ -49,6 +51,18 @@ ...@@ -49,6 +51,18 @@
end end
end end
context 'filter project with scope skipped' do
let(:query) { 'scope=skipped' }
let(:json_build) { json_response.first }
it 'return builds with status skipped' do
expect(response).to have_http_status 200
expect(json_response).to be_an Array
expect(json_response.length).to eq 1
expect(json_build['status']).to eq 'skipped'
end
end
context 'filter project with array of scope elements' do context 'filter project with array of scope elements' do
let(:query) { 'scope[0]=pending&scope[1]=running' } let(:query) { 'scope[0]=pending&scope[1]=running' }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment