summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOswaldo Ferreira <oswaldo@gitlab.com>2017-11-13 21:36:18 -0200
committerOswaldo Ferreira <oswaldo@gitlab.com>2017-11-20 12:38:53 -0200
commitd2699aea57eaef6adee25bb453a6096b80dda28f (patch)
treebe2ea704731ce5b7126271afa38f53d4f0c6e7e9
parentbd026b6a28ac410ad455b7b915cafc9782296b6b (diff)
downloadgitlab-ce-d2699aea57eaef6adee25bb453a6096b80dda28f.tar.gz
Add issue sidebar and toggle_subscription endpoint in board issues data
-rw-r--r--app/controllers/boards/issues_controller.rb1
-rw-r--r--app/models/issue.rb7
-rw-r--r--spec/fixtures/api/schemas/issue.json2
3 files changed, 9 insertions, 1 deletions
diff --git a/app/controllers/boards/issues_controller.rb b/app/controllers/boards/issues_controller.rb
index 737656b3dcc..f8049b20b9f 100644
--- a/app/controllers/boards/issues_controller.rb
+++ b/app/controllers/boards/issues_controller.rb
@@ -84,6 +84,7 @@ module Boards
resource.as_json(
only: [:id, :iid, :project_id, :title, :confidential, :due_date, :relative_position],
labels: true,
+ sidebar_endpoints: true,
include: {
project: { only: [:id, :path] },
assignees: { only: [:id, :name, :username], methods: [:avatar_url] },
diff --git a/app/models/issue.rb b/app/models/issue.rb
index b5abc8f57b0..a9863a50d84 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -246,7 +246,12 @@ class Issue < ActiveRecord::Base
def as_json(options = {})
super(options).tap do |json|
- json[:subscribed] = subscribed?(options[:user], project) if options.key?(:user) && options[:user]
+ if options.key?(:sidebar_endpoints) && project
+ url_helper = Gitlab::Routing.url_helpers
+
+ json.merge!(issue_sidebar_endpoint: url_helper.project_issue_path(project, self, format: :json, serializer: 'sidebar'),
+ toggle_subscription_endpoint: url_helper.toggle_subscription_project_issue_path(project, self))
+ end
if options.key?(:labels)
json[:labels] = labels.as_json(
diff --git a/spec/fixtures/api/schemas/issue.json b/spec/fixtures/api/schemas/issue.json
index a55ecaa5697..b579e32c9aa 100644
--- a/spec/fixtures/api/schemas/issue.json
+++ b/spec/fixtures/api/schemas/issue.json
@@ -13,6 +13,8 @@
"confidential": { "type": "boolean" },
"due_date": { "type": ["date", "null"] },
"relative_position": { "type": "integer" },
+ "issue_sidebar_endpoint": { "type": "string" },
+ "toggle_subscription_endpoint": { "type": "string" },
"project": {
"id": { "type": "integer" },
"path": { "type": "string" }