summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelogs/unreleased/api-star-restful.yml4
-rw-r--r--doc/api/projects.md6
-rw-r--r--doc/api/v3_to_v4.md1
-rw-r--r--lib/api/projects.rb2
-rw-r--r--spec/requests/api/projects_spec.rb8
5 files changed, 13 insertions, 8 deletions
diff --git a/changelogs/unreleased/api-star-restful.yml b/changelogs/unreleased/api-star-restful.yml
new file mode 100644
index 00000000000..3e7de8cd822
--- /dev/null
+++ b/changelogs/unreleased/api-star-restful.yml
@@ -0,0 +1,4 @@
+---
+title: 'API: Moved `DELETE /projects/:id/star` to `POST /projects/:id/unstar`'
+merge_request: 9328
+author: Robert Schilling
diff --git a/doc/api/projects.md b/doc/api/projects.md
index b3136be6731..e9ef03a0c0c 100644
--- a/doc/api/projects.md
+++ b/doc/api/projects.md
@@ -609,7 +609,7 @@ Example response:
Unstars a given project. Returns status code `304` if the project is not starred.
```
-DELETE /projects/:id/star
+POST /projects/:id/unstar
```
| Attribute | Type | Required | Description |
@@ -617,7 +617,7 @@ DELETE /projects/:id/star
| `id` | integer/string | yes | The ID of the project or NAMESPACE/PROJECT_NAME |
```bash
-curl --request DELETE --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/5/star"
+curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/projects/5/unstar"
```
Example response:
@@ -1194,4 +1194,4 @@ Parameters:
| --------- | ---- | -------- | ----------- |
| `query` | string | yes | A string contained in the project name |
| `order_by` | string | no | Return requests ordered by `id`, `name`, `created_at` or `last_activity_at` fields |
-| `sort` | string | no | Return requests sorted in `asc` or `desc` order | \ No newline at end of file
+| `sort` | string | no | Return requests sorted in `asc` or `desc` order |
diff --git a/doc/api/v3_to_v4.md b/doc/api/v3_to_v4.md
index 0e7c5251329..149927250f2 100644
--- a/doc/api/v3_to_v4.md
+++ b/doc/api/v3_to_v4.md
@@ -13,6 +13,7 @@ changes are in V4:
- Project snippets do not return deprecated field `expires_at`
- Endpoints under `projects/:id/keys` have been removed (use `projects/:id/deploy_keys`)
- Status 409 returned for POST `project/:id/members` when a member already exists
+- Moved `DELETE /projects/:id/star` to `POST /projects/:id/unstar`
- Removed the following deprecated Templates endpoints (these are still accessible with `/templates` prefix)
- `/licences`
- `/licences/:key`
diff --git a/lib/api/projects.rb b/lib/api/projects.rb
index 68c2732ec80..366e5679edd 100644
--- a/lib/api/projects.rb
+++ b/lib/api/projects.rb
@@ -266,7 +266,7 @@ module API
desc 'Unstar a project' do
success Entities::Project
end
- delete ':id/star' do
+ post ':id/unstar' do
if current_user.starred?(user_project)
current_user.toggle_star(user_project)
user_project.reload
diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb
index db70b63917e..4e90aae9279 100644
--- a/spec/requests/api/projects_spec.rb
+++ b/spec/requests/api/projects_spec.rb
@@ -1235,7 +1235,7 @@ describe API::Projects, api: true do
end
end
- describe 'DELETE /projects/:id/star' do
+ describe 'POST /projects/:id/unstar' do
context 'on a starred project' do
before do
user.toggle_star(project)
@@ -1243,16 +1243,16 @@ describe API::Projects, api: true do
end
it 'unstars the project' do
- expect { delete api("/projects/#{project.id}/star", user) }.to change { project.reload.star_count }.by(-1)
+ expect { post api("/projects/#{project.id}/unstar", user) }.to change { project.reload.star_count }.by(-1)
- expect(response).to have_http_status(200)
+ expect(response).to have_http_status(201)
expect(json_response['star_count']).to eq(0)
end
end
context 'on an unstarred project' do
it 'does not modify the star count' do
- expect { delete api("/projects/#{project.id}/star", user) }.not_to change { project.reload.star_count }
+ expect { post api("/projects/#{project.id}/unstar", user) }.not_to change { project.reload.star_count }
expect(response).to have_http_status(304)
end