summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Schilling <rschilling@student.tugraz.at>2016-07-19 13:05:56 +0200
committerRobert Schilling <rschilling@student.tugraz.at>2016-07-19 13:09:57 +0200
commitbaa9ce848070e76ebec12322f938ac8ec7178cf0 (patch)
tree2b752ca64459af860f621a2f612b3f4dcba777ab
parent50abec8ca36c5cbdb1f7878b3ac956211fc67d3d (diff)
downloadgitlab-ce-api-delete-todos.tar.gz
Return the number of marked todosapi-delete-todos
-rw-r--r--doc/api/todos.md152
-rw-r--r--lib/api/todos.rb2
-rw-r--r--spec/requests/api/todos_spec.rb3
3 files changed, 4 insertions, 153 deletions
diff --git a/doc/api/todos.md b/doc/api/todos.md
index 23f6e35f2a4..937c71de386 100644
--- a/doc/api/todos.md
+++ b/doc/api/todos.md
@@ -277,8 +277,7 @@ Example Response:
## Mark all todos as done
-Marks all pending todos for the current user as done. All todos marked as done
-are returned in the response.
+Marks all pending todos for the current user as done. It returns the number of marked todos.
```
DELETE /todos
@@ -291,154 +290,7 @@ curl -X DELETE -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.c
Example Response:
```json
-[
- {
- "id": 102,
- "project": {
- "id": 2,
- "name": "Gitlab Ce",
- "name_with_namespace": "Gitlab Org / Gitlab Ce",
- "path": "gitlab-ce",
- "path_with_namespace": "gitlab-org/gitlab-ce"
- },
- "author": {
- "name": "Administrator",
- "username": "root",
- "id": 1,
- "state": "active",
- "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
- "web_url": "https://gitlab.example.com/u/root"
- },
- "action_name": "marked",
- "target_type": "MergeRequest",
- "target": {
- "id": 34,
- "iid": 7,
- "project_id": 2,
- "title": "Dolores in voluptatem tenetur praesentium omnis repellendus voluptatem quaerat.",
- "description": "Et ea et omnis illum cupiditate. Dolor aspernatur tenetur ducimus facilis est nihil. Quo esse cupiditate molestiae illo corrupti qui quidem dolor.",
- "state": "opened",
- "created_at": "2016-06-17T07:49:24.419Z",
- "updated_at": "2016-06-17T07:52:43.484Z",
- "target_branch": "tutorials_git_tricks",
- "source_branch": "DNSBL_docs",
- "upvotes": 0,
- "downvotes": 0,
- "author": {
- "name": "Maxie Medhurst",
- "username": "craig_rutherford",
- "id": 12,
- "state": "active",
- "avatar_url": "http://www.gravatar.com/avatar/a0d477b3ea21970ce6ffcbb817b0b435?s=80&d=identicon",
- "web_url": "https://gitlab.example.com/u/craig_rutherford"
- },
- "assignee": {
- "name": "Administrator",
- "username": "root",
- "id": 1,
- "state": "active",
- "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
- "web_url": "https://gitlab.example.com/u/root"
- },
- "source_project_id": 2,
- "target_project_id": 2,
- "labels": [],
- "work_in_progress": false,
- "milestone": {
- "id": 32,
- "iid": 2,
- "project_id": 2,
- "title": "v1.0",
- "description": "Assumenda placeat ea voluptatem voluptate qui.",
- "state": "active",
- "created_at": "2016-06-17T07:47:34.163Z",
- "updated_at": "2016-06-17T07:47:34.163Z",
- "due_date": null
- },
- "merge_when_build_succeeds": false,
- "merge_status": "cannot_be_merged",
- "subscribed": true,
- "user_notes_count": 7
- },
- "target_url": "https://gitlab.example.com/gitlab-org/gitlab-ce/merge_requests/7",
- "body": "Dolores in voluptatem tenetur praesentium omnis repellendus voluptatem quaerat.",
- "state": "done",
- "created_at": "2016-06-17T07:52:35.225Z"
- },
- {
- "id": 98,
- "project": {
- "id": 2,
- "name": "Gitlab Ce",
- "name_with_namespace": "Gitlab Org / Gitlab Ce",
- "path": "gitlab-ce",
- "path_with_namespace": "gitlab-org/gitlab-ce"
- },
- "author": {
- "name": "Maxie Medhurst",
- "username": "craig_rutherford",
- "id": 12,
- "state": "active",
- "avatar_url": "http://www.gravatar.com/avatar/a0d477b3ea21970ce6ffcbb817b0b435?s=80&d=identicon",
- "web_url": "https://gitlab.example.com/u/craig_rutherford"
- },
- "action_name": "assigned",
- "target_type": "MergeRequest",
- "target": {
- "id": 34,
- "iid": 7,
- "project_id": 2,
- "title": "Dolores in voluptatem tenetur praesentium omnis repellendus voluptatem quaerat.",
- "description": "Et ea et omnis illum cupiditate. Dolor aspernatur tenetur ducimus facilis est nihil. Quo esse cupiditate molestiae illo corrupti qui quidem dolor.",
- "state": "opened",
- "created_at": "2016-06-17T07:49:24.419Z",
- "updated_at": "2016-06-17T07:52:43.484Z",
- "target_branch": "tutorials_git_tricks",
- "source_branch": "DNSBL_docs",
- "upvotes": 0,
- "downvotes": 0,
- "author": {
- "name": "Maxie Medhurst",
- "username": "craig_rutherford",
- "id": 12,
- "state": "active",
- "avatar_url": "http://www.gravatar.com/avatar/a0d477b3ea21970ce6ffcbb817b0b435?s=80&d=identicon",
- "web_url": "https://gitlab.example.com/u/craig_rutherford"
- },
- "assignee": {
- "name": "Administrator",
- "username": "root",
- "id": 1,
- "state": "active",
- "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
- "web_url": "https://gitlab.example.com/u/root"
- },
- "source_project_id": 2,
- "target_project_id": 2,
- "labels": [],
- "work_in_progress": false,
- "milestone": {
- "id": 32,
- "iid": 2,
- "project_id": 2,
- "title": "v1.0",
- "description": "Assumenda placeat ea voluptatem voluptate qui.",
- "state": "active",
- "created_at": "2016-06-17T07:47:34.163Z",
- "updated_at": "2016-06-17T07:47:34.163Z",
- "due_date": null
- },
- "merge_when_build_succeeds": false,
- "merge_status": "cannot_be_merged",
- "subscribed": true,
- "user_notes_count": 7
- },
- "target_url": "https://gitlab.example.com/gitlab-org/gitlab-ce/merge_requests/7",
- "body": "Dolores in voluptatem tenetur praesentium omnis repellendus voluptatem quaerat.",
- "state": "done",
- "created_at": "2016-06-17T07:49:24.624Z"
- },
-]
+3
```
[ce-3188]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/3188
diff --git a/lib/api/todos.rb b/lib/api/todos.rb
index 2a6bfa98ca4..26c24c3baff 100644
--- a/lib/api/todos.rb
+++ b/lib/api/todos.rb
@@ -75,7 +75,7 @@ module API
todos = find_todos
todos.each(&:done)
- present paginate(Kaminari.paginate_array(todos)), with: Entities::Todo, current_user: current_user
+ todos.length
end
end
end
diff --git a/spec/requests/api/todos_spec.rb b/spec/requests/api/todos_spec.rb
index 92a4fa216cd..3ccd0af652f 100644
--- a/spec/requests/api/todos_spec.rb
+++ b/spec/requests/api/todos_spec.rb
@@ -134,8 +134,7 @@ describe API::Todos, api: true do
delete api('/todos', john_doe)
expect(response.status).to eq(200)
- expect(json_response).to be_an Array
- expect(json_response.length).to eq(3)
+ expect(response.body).to eq('3')
expect(pending_1.reload).to be_done
expect(pending_2.reload).to be_done
expect(pending_3.reload).to be_done