Commit eeba266e authored by Valery Sizov's avatar Valery Sizov

Merge branch 'upvote_count_to_api' into 'master'

Revert upvotes and downvotes params back to MR API

issue https://gitlab.com/gitlab-org/gitlab-ce/issues/3672

See merge request !2212
parents a1251746 d3807328
...@@ -95,14 +95,12 @@ module Issuable ...@@ -95,14 +95,12 @@ module Issuable
opened? || reopened? opened? || reopened?
end end
# Deprecated. Still exists to preserve API compatibility.
def downvotes def downvotes
0 notes.awards.where(note: "thumbsdown").count
end end
# Deprecated. Still exists to preserve API compatibility.
def upvotes def upvotes
0 notes.awards.where(note: "thumbsup").count
end end
def subscribed?(user) def subscribed?(user)
......
...@@ -346,14 +346,12 @@ class Note < ActiveRecord::Base ...@@ -346,14 +346,12 @@ class Note < ActiveRecord::Base
read_attribute(:system) read_attribute(:system)
end end
# Deprecated. Still exists to preserve API compatibility.
def downvote? def downvote?
false is_award && note == "thumbsdown"
end end
# Deprecated. Still exists to preserve API compatibility.
def upvote? def upvote?
false is_award && note == "thumbsup"
end end
def editable? def editable?
......
...@@ -4,8 +4,7 @@ ...@@ -4,8 +4,7 @@
Get all merge requests for this project. 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 `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 The pagination parameters `page` and `per_page` can be used to restrict the list of merge requests.
`downvotes` are deprecated and always return `0`.
``` ```
GET /projects/:id/merge_requests GET /projects/:id/merge_requests
...@@ -58,7 +57,7 @@ Parameters: ...@@ -58,7 +57,7 @@ Parameters:
## Get single MR ## Get single MR
Shows information about a single merge request. With GitLab 8.2 the return fields `upvotes` and `downvotes` are deprecated and always return `0`. Shows information about a single merge request.
``` ```
GET /projects/:id/merge_request/:merge_request_id GET /projects/:id/merge_request/:merge_request_id
...@@ -141,8 +140,6 @@ Parameters: ...@@ -141,8 +140,6 @@ Parameters:
## Get single MR changes ## 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 GET /projects/:id/merge_request/:merge_request_id/changes
...@@ -213,9 +210,7 @@ Parameters: ...@@ -213,9 +210,7 @@ Parameters:
## Create MR ## Create MR
Creates a new merge request. With GitLab 8.2 the return fields `upvotes` and ` Creates a new merge request.
downvotes` are deprecated and always return `0`.
``` ```
POST /projects/:id/merge_requests POST /projects/:id/merge_requests
``` ```
...@@ -266,8 +261,7 @@ If an error occurs, an error number and a message explaining the reason is retur ...@@ -266,8 +261,7 @@ If an error occurs, an error number and a message explaining the reason is retur
## Update MR ## Update 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` Updates an existing merge request. You can change the target branch, title, or even close the MR.
are deprecated and always return `0`.
``` ```
PUT /projects/:id/merge_request/:merge_request_id PUT /projects/:id/merge_request/:merge_request_id
...@@ -318,8 +312,7 @@ If an error occurs, an error number and a message explaining the reason is retur ...@@ -318,8 +312,7 @@ If an error occurs, an error number and a message explaining the reason is retur
## Accept MR ## Accept MR
Merge changes submitted with MR using this API. With GitLab 8.2 the return Merge changes submitted with MR using this API.
fields `upvotes` and `downvotes` are deprecated and always return `0`.
If merge success you get `200 OK`. If merge success you get `200 OK`.
......
...@@ -6,8 +6,7 @@ Notes are comments on snippets, issues or merge requests. ...@@ -6,8 +6,7 @@ Notes are comments on snippets, issues or merge requests.
### List project issue notes ### List project issue notes
Gets a list of all notes for a single issue. With GitLab 8.2 the return fields Gets a list of all notes for a single issue.
`upvote` and `downvote` are deprecated and always return `false`.
``` ```
GET /projects/:id/issues/:issue_id/notes GET /projects/:id/issues/:issue_id/notes
......
...@@ -166,7 +166,6 @@ module API ...@@ -166,7 +166,6 @@ module API
class MergeRequest < ProjectEntity class MergeRequest < ProjectEntity
expose :target_branch, :source_branch expose :target_branch, :source_branch
# deprecated, always returns 0
expose :upvotes, :downvotes expose :upvotes, :downvotes
expose :author, :assignee, using: Entities::UserBasic expose :author, :assignee, using: Entities::UserBasic
expose :source_project_id, :target_project_id expose :source_project_id, :target_project_id
......
...@@ -99,4 +99,18 @@ describe Issue, "Issuable" do ...@@ -99,4 +99,18 @@ describe Issue, "Issuable" do
to eq({ 'Author' => 'Robert', 'Assignee' => 'Douwe' }) to eq({ 'Author' => 'Robert', 'Assignee' => 'Douwe' })
end end
end end
describe "votes" do
before do
author = create :user
project = create :empty_project
issue.notes.awards.create!(note: "thumbsup", author: author, project: project)
issue.notes.awards.create!(note: "thumbsdown", author: author, project: project)
end
it "returns correct values" do
expect(issue.upvotes).to eq(1)
expect(issue.downvotes).to eq(1)
end
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment