Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
GitLab
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
projects.thm.de
GitLab
Commits
1ef911f0
Commit
1ef911f0
authored
Feb 21, 2017
by
Robert Schilling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API: Use POST requests to mark todos as done
parent
b596dd8f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
26 deletions
+28
-26
changelogs/unreleased/api-todos-restful.yml
changelogs/unreleased/api-todos-restful.yml
+4
-0
doc/api/todos.md
doc/api/todos.md
+5
-10
doc/api/v3_to_v4.md
doc/api/v3_to_v4.md
+1
-1
lib/api/todos.rb
lib/api/todos.rb
+4
-2
spec/requests/api/todos_spec.rb
spec/requests/api/todos_spec.rb
+14
-13
No files found.
changelogs/unreleased/api-todos-restful.yml
0 → 100644
View file @
1ef911f0
---
title
:
'
API:
Use
POST
requests
to
mark
todos
as
done'
merge_request
:
9410
author
:
Robert Schilling
doc/api/todos.md
View file @
1ef911f0
...
...
@@ -184,7 +184,7 @@ Marks a single pending todo given by its ID for the current user as done. The
todo marked as done is returned in the response.
```
DELETE /todos/:id
POST /todos/:id/mark_as_done
```
Parameters:
...
...
@@ -194,7 +194,7 @@ Parameters:
|
`id`
| integer | yes | The ID of a todo |
```
bash
curl
--request
DELETE
--header
"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"
https://gitlab.example.com/api/v3/todos/130
curl
--request
POST
--header
"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"
https://gitlab.example.com/api/v3/todos/130/mark_as_done
```
Example Response:
...
...
@@ -277,20 +277,15 @@ Example Response:
## Mark all todos as done
Marks all pending todos for the current user as done. It returns the
number of marked todos
.
Marks all pending todos for the current user as done. It returns the
HTTP status code
`204`
with an empty response
.
```
DELETE /todos
POST /todos/mark_as_done
```
```
bash
curl
--request
DELETE
--header
"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"
https://gitlab.example.com/api/v3/todos
curl
--request
POST
--header
"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"
https://gitlab.example.com/api/v3/todos/donmark_as_donee
```
Example Response:
```
json
3
```
[
ce-3188
]:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/3188
doc/api/v3_to_v4.md
View file @
1ef911f0
...
...
@@ -24,9 +24,9 @@ changes are in V4:
-
`/gitlab_ci_ymls/:key`
-
`/dockerfiles/:key`
-
Moved
`/projects/fork/:id`
to
`/projects/:id/fork`
-
Moved
`DELETE /todos`
to
`POST /todos/mark_as_done`
and
`DELETE /todos/:todo_id`
to
`POST /todos/:todo_id/mark_as_done`
-
Endpoints
`/projects/owned`
,
`/projects/visible`
,
`/projects/starred`
&
`/projects/all`
are consolidated into
`/projects`
using query parameters
-
Return pagination headers for all endpoints that return an array
-
Removed
`DELETE projects/:id/deploy_keys/:key_id/disable`
. Use
`DELETE projects/:id/deploy_keys/:key_id`
instead
-
Moved
`PUT /users/:id/(block|unblock)`
to
`POST /users/:id/(block|unblock)`
-
Labels filter on
`projects/:id/issues`
and
`/issues`
now matches only issues containing all labels (i.e.: Logical AND, not OR)
lib/api/todos.rb
View file @
1ef911f0
...
...
@@ -58,7 +58,7 @@ def find_todos
params
do
requires
:id
,
type:
Integer
,
desc:
'The ID of the todo being marked as done'
end
delete
':id
'
do
post
':id/mark_as_done
'
do
todo
=
current_user
.
todos
.
find
(
params
[
:id
])
TodoService
.
new
.
mark_todos_as_done
([
todo
],
current_user
)
...
...
@@ -66,9 +66,11 @@ def find_todos
end
desc
'Mark all todos as done'
delete
do
post
'/mark_as_done'
do
todos
=
find_todos
TodoService
.
new
.
mark_todos_as_done
(
todos
,
current_user
)
no_content!
end
end
end
...
...
spec/requests/api/todos_spec.rb
View file @
1ef911f0
...
...
@@ -107,46 +107,47 @@
end
end
describe
'
DELETE /todos/:id
'
do
describe
'
POST /todos/:id/mark_as_done
'
do
context
'when unauthenticated'
do
it
'returns authentication error'
do
delete
api
(
"/todos/
#{
pending_1
.
id
}
"
)
post
api
(
"/todos/
#{
pending_1
.
id
}
/mark_as_done
"
)
expect
(
response
.
status
).
to
eq
(
401
)
expect
(
response
).
to
have_http_status
(
401
)
end
end
context
'when authenticated'
do
it
'marks a todo as done'
do
delete
api
(
"/todos/
#{
pending_1
.
id
}
"
,
john_doe
)
post
api
(
"/todos/
#{
pending_1
.
id
}
/mark_as_done
"
,
john_doe
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
).
to
have_http_status
(
201
)
expect
(
json_response
[
'id'
]).
to
eq
(
pending_1
.
id
)
expect
(
json_response
[
'state'
]).
to
eq
(
'done'
)
expect
(
pending_1
.
reload
).
to
be_done
end
it
'updates todos cache'
do
expect_any_instance_of
(
User
).
to
receive
(
:update_todos_count_cache
).
and_call_original
delete
api
(
"/todos/
#{
pending_1
.
id
}
"
,
john_doe
)
post
api
(
"/todos/
#{
pending_1
.
id
}
/mark_as_done
"
,
john_doe
)
end
end
end
describe
'
DELETE /todos
'
do
describe
'
POST /mark_as_done
'
do
context
'when unauthenticated'
do
it
'returns authentication error'
do
delete
api
(
'/todos
'
)
post
api
(
'/todos/mark_as_done
'
)
expect
(
response
.
status
).
to
eq
(
401
)
expect
(
response
).
to
have_http_status
(
401
)
end
end
context
'when authenticated'
do
it
'marks all todos as done'
do
delete
api
(
'/todos
'
,
john_doe
)
post
api
(
'/todos/mark_as_done
'
,
john_doe
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
body
).
to
eq
(
'3'
)
expect
(
response
).
to
have_http_status
(
204
)
expect
(
pending_1
.
reload
).
to
be_done
expect
(
pending_2
.
reload
).
to
be_done
expect
(
pending_3
.
reload
).
to
be_done
...
...
@@ -155,7 +156,7 @@
it
'updates todos cache'
do
expect_any_instance_of
(
User
).
to
receive
(
:update_todos_count_cache
).
and_call_original
delete
api
(
"/todos
"
,
john_doe
)
post
api
(
"/todos/mark_as_done
"
,
john_doe
)
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment