Commit 53644007 authored by cnam-dep's avatar cnam-dep Committed by Rémy Coutable

API: Expose Issue#user_notes_count

parent 618033fb
......@@ -51,6 +51,9 @@ v 8.7.2
- Label titles in filters are now escaped properly
v 8.7.1
- API: Expose Issue#user_notes_count (Anton Popov)
v 8.7.1 (unreleased)
- Throttle the update of `project.last_activity_at` to 1 minute. !3848
- Fix .gitlab-ci.yml parsing issue when hidde job is a template without script definition. !3849
- Fix license detection to detect all license files, not only known licenses. !3878
......
......@@ -160,6 +160,10 @@ module Issuable
notes.awards.where(note: "thumbsup").count
end
def user_notes_count
notes.user.count
end
def subscribed_without_subscriptions?(user)
participants(user).include?(user)
end
......
......@@ -77,7 +77,8 @@ Example response:
"created_at" : "2016-01-04T15:31:51.081Z",
"iid" : 6,
"labels" : [],
"subscribed" : false
"subscribed" : false,
"user_notes_count": 1
}
]
```
......@@ -154,7 +155,8 @@ Example response:
"title" : "Ut commodi ullam eos dolores perferendis nihil sunt.",
"updated_at" : "2016-01-04T15:31:46.176Z",
"created_at" : "2016-01-04T15:31:46.176Z",
"subscribed" : false
"subscribed" : false,
"user_notes_count": 1
}
]
```
......@@ -216,7 +218,8 @@ Example response:
"title" : "Ut commodi ullam eos dolores perferendis nihil sunt.",
"updated_at" : "2016-01-04T15:31:46.176Z",
"created_at" : "2016-01-04T15:31:46.176Z",
"subscribed": false
"subscribed": false,
"user_notes_count": 1
}
```
......@@ -271,7 +274,8 @@ Example response:
"description" : null,
"updated_at" : "2016-01-07T12:44:33.959Z",
"milestone" : null,
"subscribed" : true
"subscribed" : true,
"user_notes_count": 0
}
```
......@@ -329,7 +333,8 @@ Example response:
"id" : 85,
"assignee" : null,
"milestone" : null,
"subscribed" : true
"subscribed" : true,
"user_notes_count": 0
}
```
......
......@@ -170,10 +170,10 @@ module API
expose :label_names, as: :labels
expose :milestone, using: Entities::Milestone
expose :assignee, :author, using: Entities::UserBasic
expose :subscribed do |issue, options|
issue.subscribed?(options[:current_user])
end
expose :user_notes_count
end
class MergeRequest < ProjectEntity
......
......@@ -39,6 +39,7 @@ describe API::API, api: true do
let!(:empty_milestone) do
create(:milestone, title: '2.0.0', project: project)
end
let!(:issue_note) { create(:note, noteable: issue, project: project, author: user) }
before { project.team << [user, :reporter] }
......@@ -128,6 +129,13 @@ describe API::API, api: true do
expect(json_response).to be_an Array
expect(json_response.length).to eq(0)
end
it 'should return an count notes in issue' do
get api("/issues", user)
expect(response.status).to eq(200)
expect(json_response).to be_an Array
expect(json_response.first['user_notes_count']).to eq(1)
end
end
end
......@@ -229,6 +237,13 @@ describe API::API, api: true do
expect(json_response.length).to eq(1)
expect(json_response.first['id']).to eq(closed_issue.id)
end
it 'should return an count notes in issue' do
get api("#{base_url}/issues", user)
expect(response.status).to eq(200)
expect(json_response).to be_an Array
expect(json_response.first['user_notes_count']).to eq(1)
end
end
describe "GET /projects/:id/issues/:issue_id" do
......
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