summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-11-25 16:51:53 +0000
committerRémy Coutable <remy@rymai.me>2016-11-25 16:51:53 +0000
commite17328986abcaabff47edb6292ede7546f607bb2 (patch)
treea87a93a0d65a48a3724dc41cd8e9c161e77e728b
parent746b6ec82d1ed29a679fe4dc6a93b2d0228e9d34 (diff)
parent752d72f87635c1f43f3334d7e2dd96ab77eeba7d (diff)
downloadgitlab-ce-e17328986abcaabff47edb6292ede7546f607bb2.tar.gz
Merge branch 'zj-expose-coverage-pipelines' into 'master'
Expose coverage on GET pipelines/:id Closes gitlab-org/gitlab-ce#24801 See merge request !7670
-rw-r--r--changelogs/unreleased/zj-expose-coverage-pipelines.yml4
-rw-r--r--doc/api/pipelines.md18
-rw-r--r--lib/api/entities.rb1
-rw-r--r--spec/requests/api/pipelines_spec.rb12
4 files changed, 29 insertions, 6 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/doc/api/pipelines.md b/doc/api/pipelines.md
index 6455c333faf..82351ae688f 100644
--- a/doc/api/pipelines.md
+++ b/doc/api/pipelines.md
@@ -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
}
```
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 7a724487e02..fdb19558c1c 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -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
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