Expose Label id to API

[e44da1c] Add Label API expected keys to tests

[ac929c8] Update Label API documentation
This commit is contained in:
Rares Sfirlogea 2016-11-04 12:52:38 +01:00
parent 717b8a7692
commit 63f0b09974
4 changed files with 111 additions and 90 deletions

View file

@ -0,0 +1,4 @@
---
title: Expose label IDs in API
merge_request: 7275
author: Rares Sfirlogea

View file

@ -21,6 +21,7 @@ Example response:
```json
[
{
"id" : 1,
"name" : "bug",
"color" : "#d9534f",
"description": "Bug reported by user",
@ -31,6 +32,7 @@ Example response:
"priority": 10
},
{
"id" : 4,
"color" : "#d9534f",
"name" : "confirmed",
"description": "Confirmed issue",
@ -41,6 +43,7 @@ Example response:
"priority": null
},
{
"id" : 7,
"name" : "critical",
"color" : "#d9534f",
"description": "Critical issue. Need fix ASAP",
@ -51,6 +54,7 @@ Example response:
"priority": null
},
{
"id" : 8,
"name" : "documentation",
"color" : "#f0ad4e",
"description": "Issue about documentation",
@ -61,13 +65,14 @@ Example response:
"priority": null
},
{
"id" : 9,
"color" : "#5cb85c",
"name" : "enhancement",
"description": "Enhancement proposal",
"open_issues_count": 1,
"closed_issues_count": 0,
"open_merge_requests_count": 1,
"subscribed": false,
"subscribed": true,
"priority": null
}
]
@ -100,12 +105,14 @@ Example response:
```json
{
"id" : 10,
"name" : "feature",
"color" : "#5843AD",
"open_issues_count": 1,
"description":null,
"open_issues_count": 0,
"closed_issues_count": 0,
"open_merge_requests_count": 1,
"description": null,
"open_merge_requests_count": 0,
"subscribed": false,
"priority": null
}
```
@ -135,14 +142,14 @@ Example response:
```json
{
"title" : "feature",
"color" : "#5843AD",
"description": "New feature proposal",
"updated_at" : "2015-11-03T21:22:30.737Z",
"template" : false,
"project_id" : 1,
"created_at" : "2015-11-03T21:22:30.737Z",
"id" : 9,
"id" : 1,
"name" : "bug",
"color" : "#d9534f",
"description": "Bug reported by user",
"open_issues_count": 1,
"closed_issues_count": 0,
"open_merge_requests_count": 1,
"subscribed": false,
"priority": null
}
```
@ -178,12 +185,14 @@ Example response:
```json
{
"color" : "#8E44AD",
"id" : 8,
"name" : "docs",
"color" : "#8E44AD",
"description": "Documentation",
"open_issues_count": 1,
"closed_issues_count": 0,
"open_merge_requests_count": 1,
"open_merge_requests_count": 2,
"subscribed": false,
"priority": null
}
```
@ -213,12 +222,13 @@ Example response:
```json
{
"name": "Docs",
"color": "#cc0033",
"description": "",
"open_issues_count": 0,
"id" : 1,
"name" : "bug",
"color" : "#d9534f",
"description": "Bug reported by user",
"open_issues_count": 1,
"closed_issues_count": 0,
"open_merge_requests_count": 0,
"open_merge_requests_count": 1,
"subscribed": true,
"priority": null
}
@ -249,12 +259,13 @@ Example response:
```json
{
"name": "Docs",
"color": "#cc0033",
"description": "",
"open_issues_count": 0,
"id" : 1,
"name" : "bug",
"color" : "#d9534f",
"description": "Bug reported by user",
"open_issues_count": 1,
"closed_issues_count": 0,
"open_merge_requests_count": 0,
"open_merge_requests_count": 1,
"subscribed": false,
"priority": null
}

View file

@ -433,7 +433,7 @@ module API
end
class LabelBasic < Grape::Entity
expose :name, :color, :description
expose :id, :name, :color, :description
end
class Label < LabelBasic

View file

@ -17,12 +17,18 @@ describe API::API, api: true do
group = create(:group)
group_label = create(:group_label, group: group)
project.update(group: group)
expected_keys = [
'id', 'name', 'color', 'description',
'open_issues_count', 'closed_issues_count', 'open_merge_requests_count',
'subscribed', 'priority'
]
get api("/projects/#{project.id}/labels", user)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
expect(json_response.size).to eq(3)
expect(json_response.first.keys).to match_array expected_keys
expect(json_response.map { |l| l['name'] }).to match_array([group_label.name, priority_label.name, label1.name])
expect(json_response.last['name']).to eq(label1.name)
expect(json_response.last['color']).to be_present