diff options
author | Z.J. van de Weg <git@zjvandeweg.nl> | 2016-11-22 17:28:58 +0100 |
---|---|---|
committer | Z.J. van de Weg <git@zjvandeweg.nl> | 2016-11-25 15:49:59 +0100 |
commit | 40e8185b64a04f719c85a793d0fdd5438a129975 (patch) | |
tree | afbe2bb812256a458467c595a25e44beeb003c9e | |
parent | da0dd7ec96b99eb3e357db2ae8ab4f6d11bfcebb (diff) | |
download | gitlab-ce-zj-expose-coverage-pipelines.tar.gz |
Expose coverage on GET pipelines/:idzj-expose-coverage-pipelines
The coverage wasn't exposed yet, now it is but only for detailed
requests to save queries on the database.
-rw-r--r-- | changelogs/unreleased/zj-expose-coverage-pipelines.yml | 4 | ||||
-rw-r--r-- | lib/api/entities.rb | 1 | ||||
-rw-r--r-- | spec/requests/api/pipelines_spec.rb | 12 |
3 files changed, 17 insertions, 0 deletions
diff --git a/changelogs/unreleased/zj-expose-coverage-pipelines.yml b/changelogs/unreleased/zj-expose-coverage-pipelines.yml new file mode 100644 index 00000000000..34e4926e58a --- /dev/null +++ b/changelogs/unreleased/zj-expose-coverage-pipelines.yml @@ -0,0 +1,4 @@ +--- +title: 'API: expose pipeline coverage' +merge_request: +author: diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 33cb6fd3704..7dfaf2e8eb7 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -606,6 +606,7 @@ module API expose :user, with: Entities::UserBasic expose :created_at, :updated_at, :started_at, :finished_at, :committed_at expose :duration + expose :coverage end class EnvironmentBasic < Grape::Entity diff --git a/spec/requests/api/pipelines_spec.rb b/spec/requests/api/pipelines_spec.rb index d83f7883c78..a7e511aaeda 100644 --- a/spec/requests/api/pipelines_spec.rb +++ b/spec/requests/api/pipelines_spec.rb @@ -103,6 +103,18 @@ describe API::API, api: true do expect(json_response['message']).to eq '404 Not found' expect(json_response['id']).to be nil end + + context 'with coverage' do + before do + create(:ci_build, coverage: 30, pipeline: pipeline) + end + + it 'exposes the coverage' do + get api("/projects/#{project.id}/pipelines/#{pipeline.id}", user) + + expect(json_response["coverage"].to_i).to eq(30) + end + end end context 'unauthorized user' do |