summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Schilling <rschilling@student.tugraz.at>2015-11-21 21:36:31 +0100
committerRobert Schilling <rschilling@student.tugraz.at>2015-11-21 21:36:31 +0100
commit26b12e2c374c8f07abda06a8b19bd116448325f4 (patch)
tree123d044cbb8c7a3f2bebdddcc859f79eada5c6e8
parent319808fc7be2886224541209eeae153d85386bd0 (diff)
downloadgitlab-ce-26b12e2c374c8f07abda06a8b19bd116448325f4.tar.gz
Add upvote/downvote fields to merge request and note API to preserve compatibilityfix-award-emoji-api
-rw-r--r--app/models/concerns/issuable.rb10
-rw-r--r--app/models/note.rb10
-rw-r--r--doc/api/merge_requests.md32
-rw-r--r--doc/api/notes.md11
-rw-r--r--lib/api/entities.rb5
5 files changed, 58 insertions, 10 deletions
diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb
index 2dafb5e752f..98ad5e76da7 100644
--- a/app/models/concerns/issuable.rb
+++ b/app/models/concerns/issuable.rb
@@ -92,6 +92,16 @@ module Issuable
opened? || reopened?
end
+ # Deprecated. Still exists to preserve API compatibility.
+ def downvotes
+ 0
+ end
+
+ # Deprecated. Still exists to preserve API compatibility.
+ def upvotes
+ 0
+ end
+
def subscribed?(user)
subscription = subscriptions.find_by_user_id(user.id)
diff --git a/app/models/note.rb b/app/models/note.rb
index e30be444eb5..1c6345e735c 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -335,6 +335,16 @@ class Note < ActiveRecord::Base
read_attribute(:system)
end
+ # Deprecated. Still exists to preserve API compatibility.
+ def downvote?
+ false
+ end
+
+ # Deprecated. Still exists to preserve API compatibility.
+ def upvote?
+ false
+ end
+
def editable?
!system?
end
diff --git a/doc/api/merge_requests.md b/doc/api/merge_requests.md
index 2f17d4ae06b..0cef09d5b27 100644
--- a/doc/api/merge_requests.md
+++ b/doc/api/merge_requests.md
@@ -3,8 +3,9 @@
## List merge requests
Get all merge requests for this project.
-The `state` parameter can be used to get only merge requests with a given state (`opened`, `closed`, or `merged`) or all of them (`all`).
-The pagination parameters `page` and `per_page` can be used to restrict the list of merge requests.
+The `state` parameter can be used to get only merge requests with a given state (`opened`, `closed`, or `merged`) or all of them (`all`).
+The pagination parameters `page` and `per_page` can be used to restrict the list of merge requests. With GitLab 8.2 the return fields `upvotes` and
+`downvotes` are deprecated and always return `0`.
```
GET /projects/:id/merge_requests
@@ -31,6 +32,8 @@ Parameters:
"project_id": 3,
"title": "test1",
"state": "opened",
+ "upvotes": 0,
+ "downvotes": 0,
"author": {
"id": 1,
"username": "admin",
@@ -55,7 +58,7 @@ Parameters:
## Get single MR
-Shows information about a single merge request.
+Shows information about a single merge request. With GitLab 8.2 the return fields `upvotes` and `downvotes` are deprecated and always return `0`.
```
GET /projects/:id/merge_request/:merge_request_id
@@ -75,6 +78,8 @@ Parameters:
"project_id": 3,
"title": "test1",
"state": "merged",
+ "upvotes": 0,
+ "downvotes": 0,
"author": {
"id": 1,
"username": "admin",
@@ -98,7 +103,9 @@ Parameters:
## Get single MR changes
-Shows information about the merge request including its files and changes
+Shows information about the merge request including its files and changes.
+With GitLab 8.2 the return fields `upvotes` and `downvotes` are deprecated and
+always return `0`.
```
GET /projects/:id/merge_request/:merge_request_id/changes
@@ -122,6 +129,8 @@ Parameters:
"updated_at": "2015-02-02T20:08:49.959Z",
"target_branch": "secret_token",
"source_branch": "version-1-9",
+ "upvotes": 0,
+ "downvotes": 0,
"author": {
"name": "Chad Hamill",
"username": "jarrett",
@@ -167,7 +176,8 @@ Parameters:
## Create MR
-Creates a new merge request.
+Creates a new merge request. With GitLab 8.2 the return fields `upvotes` and `
+downvotes` are deprecated and always return `0`.
```
POST /projects/:id/merge_requests
@@ -192,6 +202,8 @@ Parameters:
"project_id": 3,
"title": "test1",
"state": "opened",
+ "upvotes": 0,
+ "downvotes": 0,
"author": {
"id": 1,
"username": "admin",
@@ -217,7 +229,8 @@ If an error occurs, an error number and a message explaining the reason is retur
## Update MR
-Updates an existing merge request. You can change the target branch, title, or even close the MR.
+Updates an existing merge request. You can change the target branch, title, or even close the MR. With GitLab 8.2 the return fields `upvotes` and `downvotes`
+are deprecated and always return `0`.
```
PUT /projects/:id/merge_request/:merge_request_id
@@ -242,6 +255,8 @@ Parameters:
"title": "test1",
"description": "description1",
"state": "opened",
+ "upvotes": 0,
+ "downvotes": 0,
"author": {
"id": 1,
"username": "admin",
@@ -266,7 +281,8 @@ If an error occurs, an error number and a message explaining the reason is retur
## Accept MR
-Merge changes submitted with MR using this API.
+Merge changes submitted with MR using this API. With GitLab 8.2 the return
+fields `upvotes` and `downvotes` are deprecated and always return `0`.
If merge success you get `200 OK`.
@@ -294,6 +310,8 @@ Parameters:
"project_id": 3,
"title": "test1",
"state": "merged",
+ "upvotes": 0,
+ "downvotes": 0,
"author": {
"id": 1,
"username": "admin",
diff --git a/doc/api/notes.md b/doc/api/notes.md
index bcba1f62151..e7f299c0994 100644
--- a/doc/api/notes.md
+++ b/doc/api/notes.md
@@ -6,7 +6,8 @@ Notes are comments on snippets, issues or merge requests.
### List project issue notes
-Gets a list of all notes for a single issue.
+Gets a list of all notes for a single issue. With GitLab 8.2 the return fields
+`upvote` and `downvote` are deprecated and always return `false`.
```
GET /projects/:id/issues/:issue_id/notes
@@ -32,7 +33,9 @@ Parameters:
"created_at": "2013-09-30T13:46:01Z"
},
"created_at": "2013-10-02T09:22:45Z",
- "system": true
+ "system": true,
+ "upvote": false,
+ "downvote": false
},
{
"id": 305,
@@ -47,7 +50,9 @@ Parameters:
"created_at": "2013-09-30T13:46:01Z"
},
"created_at": "2013-10-02T09:56:03Z",
- "system": false
+ "system": true,
+ "upvote": false,
+ "downvote": false
}
]
```
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 3da6bc415d6..7f9dba4b6a5 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -163,6 +163,8 @@ module API
class MergeRequest < ProjectEntity
expose :target_branch, :source_branch
+ # deprecated, always returns 0
+ expose :upvotes, :downvotes
expose :author, :assignee, using: Entities::UserBasic
expose :source_project_id, :target_project_id
expose :label_names, as: :labels
@@ -192,6 +194,9 @@ module API
expose :author, using: Entities::UserBasic
expose :created_at
expose :system?, as: :system
+ # upvote? and downvote? are deprecated, always return false
+ expose :upvote?, as: :upvote
+ expose :downvote?, as: :downvote
end
class MRNote < Grape::Entity