diff options
author | Phil Hughes <me@iamphill.com> | 2016-10-07 09:24:57 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-10-07 09:24:57 +0100 |
commit | 7d20a91b2ecf0af89b3a6d3a5d4d8621114687ec (patch) | |
tree | 3aceaa120558f70d525338d5ffd722c5d1b05b07 | |
parent | 1aff95c76844adb880e7f935deab8af5e797fb51 (diff) | |
download | gitlab-ce-7d20a91b2ecf0af89b3a6d3a5d4d8621114687ec.tar.gz |
Restore subscribe status in JSON
-rw-r--r-- | app/controllers/projects/boards/issues_controller.rb | 7 | ||||
-rw-r--r-- | app/models/issue.rb | 6 | ||||
-rw-r--r-- | spec/controllers/projects/boards/issues_controller_spec.rb | 2 | ||||
-rw-r--r-- | spec/fixtures/api/schemas/issue.json | 3 |
4 files changed, 15 insertions, 3 deletions
diff --git a/app/controllers/projects/boards/issues_controller.rb b/app/controllers/projects/boards/issues_controller.rb index b5a56d11d32..fbb06c0ffba 100644 --- a/app/controllers/projects/boards/issues_controller.rb +++ b/app/controllers/projects/boards/issues_controller.rb @@ -76,8 +76,11 @@ module Projects only: [:iid, :title, :confidential, :due_date], include: { assignee: { only: [:id, :name, :username], methods: [:avatar_url] }, - labels: { only: [:id, :title, :description, :color, :priority], methods: [:text_color] } - }) + labels: { only: [:id, :title, :description, :color, :priority], methods: [:text_color] }, + milestone: { only: [:id, :title] } + }, + user: current_user + ) end end end diff --git a/app/models/issue.rb b/app/models/issue.rb index abd58e0454a..89794290520 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -274,4 +274,10 @@ class Issue < ActiveRecord::Base def check_for_spam? project.public? end + + def as_json(options = {}) + super(options).tap do |json| + json[:subscribed] = subscribed?(options[:user]) if options.has_key?(:user) + end + end end diff --git a/spec/controllers/projects/boards/issues_controller_spec.rb b/spec/controllers/projects/boards/issues_controller_spec.rb index 0eebb5a4624..75f6e7f54e2 100644 --- a/spec/controllers/projects/boards/issues_controller_spec.rb +++ b/spec/controllers/projects/boards/issues_controller_spec.rb @@ -20,9 +20,11 @@ describe Projects::Boards::IssuesController 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'))) + issue = create(:labeled_issue, project: project, labels: [planning]) create(:labeled_issue, project: project, labels: [planning]) create(:labeled_issue, project: project, labels: [development], due_date: Date.tomorrow) create(:labeled_issue, project: project, labels: [development], assignee: johndoe) + issue.subscribe(johndoe) list_issues user: user, list_id: list2 diff --git a/spec/fixtures/api/schemas/issue.json b/spec/fixtures/api/schemas/issue.json index 6de6618e475..77f2bcee1f3 100644 --- a/spec/fixtures/api/schemas/issue.json +++ b/spec/fixtures/api/schemas/issue.json @@ -43,7 +43,8 @@ "name": { "type": "string" }, "username": { "type": "string" }, "avatar_url": { "type": "uri" } - } + }, + "subscribed": { "type": ["boolean", "null"] } }, "additionalProperties": false } |