Include the Issue#assignee in the response when listing issues

This commit is contained in:
Douglas Barbosa Alexandre 2016-08-04 14:20:26 -03:00
parent a8b2d7f380
commit 5317f6ea94
3 changed files with 14 additions and 2 deletions

View file

@ -7,7 +7,12 @@ class Projects::BoardIssuesController < Projects::ApplicationController
issues = Boards::Issues::ListService.new(project, current_user, filter_params).execute
issues = issues.page(params[:page])
render json: issues.as_json(only: [:iid, :title, :confidential], include: { labels: { only: [:id, :title, :color] } })
render json: issues.as_json(
only: [:iid, :title, :confidential],
include: {
assignee: { only: [:id, :name, :username], methods: [:avatar_url] },
labels: { only: [:id, :title, :color] }
})
end
def update

View file

@ -18,9 +18,10 @@ describe Projects::BoardIssuesController do
describe 'GET #index' do
context 'with valid list id' do
it 'returns issues that have the list label applied' do
johndoe = create(:user, avatar: fixture_file_upload(File.join(Rails.root, 'spec/fixtures/dk.png')))
create(:labeled_issue, project: project, labels: [planning])
create(:labeled_issue, project: project, labels: [development])
create(:labeled_issue, project: project, labels: [development])
create(:labeled_issue, project: project, labels: [development], assignee: johndoe)
list_issues list_id: list2

View file

@ -24,6 +24,12 @@
},
"title": { "type": "string" }
}
},
"assignee": {
"id": { "type": "integet" },
"name": { "type": "string" },
"username": { "type": "string" },
"avatar_url": { "type": "uri" }
}
},
"additionalProperties": false