Expose board project and milestone on boards API

parent d7ac635b
......@@ -567,6 +567,9 @@ module API
class Board < Grape::Entity
expose :id
expose :name
expose :project, using: Entities::BasicProjectDetails
expose :milestone
expose :lists, using: Entities::List do |board|
board.lists.destroyable
end
......
{
"type": "object",
"required" : [
"id",
"name",
"project",
"milestone",
"lists"
],
"properties" : {
"id": { "type": "integer" },
"name": { "type": "string" },
"project": {
"type": "object",
"required": [
"id",
"name",
"name_with_namespace",
"path",
"path_with_namespace",
"http_url_to_repo",
"web_url"
],
"properties": {
"id": { "type": "integer" },
"name": { "type": "string" },
"name_with_namespace": { "type": "string" },
"path": { "type": "string" },
"path_with_namespace": { "type": "string" },
"http_url_to_repo": { "type": "string" },
"web_url": { "type": "string" }
},
"additionalProperties": false
},
"milestone": {
"type": ["object", "null"],
"required": [
"id",
"title"
],
"properties": {
"id": { "type": "integer" },
"title": { "type": "string" }
},
"additionalProperties": false
},
"lists": {
"type": "array",
"items": {
"type": "object",
"required" : [
"id",
"label",
"position"
],
"properties" : {
"id": { "type": "integer" },
"label": {
"type": ["object", "null"],
"required": [
"id",
"color",
"description",
"name"
],
"properties": {
"id": { "type": "integer" },
"color": {
"type": "string",
"pattern": "^#[0-9A-Fa-f]{3}{1,2}+$"
},
"description": { "type": ["string", "null"] },
"name": { "type": "string" }
}
},
"position": { "type": ["integer", "null"] }
},
"additionalProperties": false
}
}
},
"additionalProperties": false
}
{
"type": "array",
"items": { "$ref": "board.json" }
}
......@@ -4,11 +4,11 @@ describe API::Boards, api: true do
include ApiHelpers
let(:user) { create(:user) }
let(:user2) { create(:user) }
let(:non_member) { create(:user) }
let(:guest) { create(:user) }
let(:admin) { create(:user, :admin) }
let!(:project) { create(:empty_project, :public, creator_id: user.id, namespace: user.namespace ) }
let(:milestone) { create(:milestone, project: project) }
let!(:dev_label) do
create(:label, title: 'Development', color: '#FFAABB', project: project)
......@@ -31,7 +31,7 @@ describe API::Boards, api: true do
end
let!(:board) do
create(:board, project: project, lists: [dev_list, test_list])
create(:board, project: project, milestone: milestone, lists: [dev_list, test_list])
end
before do
......@@ -56,12 +56,7 @@ describe API::Boards, api: true do
expect(response).to have_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.length).to eq(1)
expect(json_response.first['id']).to eq(board.id)
expect(json_response.first['lists']).to be_an Array
expect(json_response.first['lists'].length).to eq(2)
expect(json_response.first['lists'].last).to have_key('position')
expect(response).to match_response_schema('public_api/v4/boards')
end
end
end
......
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