From 5317f6ea943c84ec0dc68a934f953e667fae1178 Mon Sep 17 00:00:00 2001 From: Douglas Barbosa Alexandre Date: Thu, 4 Aug 2016 14:20:26 -0300 Subject: [PATCH] Include the Issue#assignee in the response when listing issues --- app/controllers/projects/board_issues_controller.rb | 7 ++++++- spec/controllers/projects/board_issues_controller_spec.rb | 3 ++- spec/fixtures/api/schemas/issue.json | 6 ++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/controllers/projects/board_issues_controller.rb b/app/controllers/projects/board_issues_controller.rb index cdaaacfbbd4..fdc3a8795ef 100644 --- a/app/controllers/projects/board_issues_controller.rb +++ b/app/controllers/projects/board_issues_controller.rb @@ -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 diff --git a/spec/controllers/projects/board_issues_controller_spec.rb b/spec/controllers/projects/board_issues_controller_spec.rb index 6b4fb382b16..44a20411abc 100644 --- a/spec/controllers/projects/board_issues_controller_spec.rb +++ b/spec/controllers/projects/board_issues_controller_spec.rb @@ -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 diff --git a/spec/fixtures/api/schemas/issue.json b/spec/fixtures/api/schemas/issue.json index 0a9bf4e0fb7..3da9b241047 100644 --- a/spec/fixtures/api/schemas/issue.json +++ b/spec/fixtures/api/schemas/issue.json @@ -24,6 +24,12 @@ }, "title": { "type": "string" } } + }, + "assignee": { + "id": { "type": "integet" }, + "name": { "type": "string" }, + "username": { "type": "string" }, + "avatar_url": { "type": "uri" } } }, "additionalProperties": false