Merge branch 'zj-expose-coverage-pipelines' into 'master'

Expose coverage on GET pipelines/:id

Closes gitlab-org/gitlab-ce#24801

See merge request !7670
This commit is contained in:
Rémy Coutable 2016-11-25 16:51:53 +00:00
commit e17328986a
4 changed files with 29 additions and 6 deletions

View File

@ -0,0 +1,4 @@
---
title: 'API: expose pipeline coverage'
merge_request:
author:

View File

@ -41,7 +41,8 @@ Example of response
"started_at": null,
"finished_at": null,
"committed_at": null,
"duration": null
"duration": null,
"coverage": "30.0"
},
{
"id": 48,
@ -64,7 +65,8 @@ Example of response
"started_at": null,
"finished_at": null,
"committed_at": null,
"duration": null
"duration": null,
"coverage": null
}
]
```
@ -110,7 +112,8 @@ Example of response
"started_at": null,
"finished_at": "2016-08-11T11:32:35.145Z",
"committed_at": null,
"duration": null
"duration": null,
"coverage": "30.0"
}
```
@ -155,7 +158,8 @@ Example of response
"started_at": null,
"finished_at": null,
"committed_at": null,
"duration": null
"duration": null,
"coverage": null
}
```
@ -200,7 +204,8 @@ Response:
"started_at": null,
"finished_at": "2016-08-11T11:32:35.145Z",
"committed_at": null,
"duration": null
"duration": null,
"coverage": null
}
```
@ -245,7 +250,8 @@ Response:
"started_at": null,
"finished_at": "2016-08-11T11:32:35.145Z",
"committed_at": null,
"duration": null
"duration": null,
"coverage": null
}
```

View File

@ -607,6 +607,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

View File

@ -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