Commit 039c6d60 authored by Robert Schilling's avatar Robert Schilling

API: Moved `DELETE /projects/:id/star` to `POST /projects/:id/unstar`

parent c89449e6
---
title: 'API: Moved `DELETE /projects/:id/star` to `POST /projects/:id/unstar`'
merge_request: 9328
author: Robert Schilling
...@@ -609,7 +609,7 @@ Example response: ...@@ -609,7 +609,7 @@ Example response:
Unstars a given project. Returns status code `304` if the project is not starred. 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 | | Attribute | Type | Required | Description |
...@@ -617,7 +617,7 @@ DELETE /projects/:id/star ...@@ -617,7 +617,7 @@ DELETE /projects/:id/star
| `id` | integer/string | yes | The ID of the project or NAMESPACE/PROJECT_NAME | | `id` | integer/string | yes | The ID of the project or NAMESPACE/PROJECT_NAME |
```bash ```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: Example response:
......
...@@ -13,6 +13,7 @@ changes are in V4: ...@@ -13,6 +13,7 @@ changes are in V4:
- Project snippets do not return deprecated field `expires_at` - Project snippets do not return deprecated field `expires_at`
- Endpoints under `projects/:id/keys` have been removed (use `projects/:id/deploy_keys`) - 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 - 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) - Removed the following deprecated Templates endpoints (these are still accessible with `/templates` prefix)
- `/licences` - `/licences`
- `/licences/:key` - `/licences/:key`
......
...@@ -266,7 +266,7 @@ module API ...@@ -266,7 +266,7 @@ module API
desc 'Unstar a project' do desc 'Unstar a project' do
success Entities::Project success Entities::Project
end end
delete ':id/star' do post ':id/unstar' do
if current_user.starred?(user_project) if current_user.starred?(user_project)
current_user.toggle_star(user_project) current_user.toggle_star(user_project)
user_project.reload user_project.reload
......
...@@ -1235,7 +1235,7 @@ describe API::Projects, api: true do ...@@ -1235,7 +1235,7 @@ describe API::Projects, api: true do
end end
end end
describe 'DELETE /projects/:id/star' do describe 'POST /projects/:id/unstar' do
context 'on a starred project' do context 'on a starred project' do
before do before do
user.toggle_star(project) user.toggle_star(project)
...@@ -1243,16 +1243,16 @@ describe API::Projects, api: true do ...@@ -1243,16 +1243,16 @@ describe API::Projects, api: true do
end end
it 'unstars the project' do 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) expect(json_response['star_count']).to eq(0)
end end
end end
context 'on an unstarred project' do context 'on an unstarred project' do
it 'does not modify the star count' 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) expect(response).to have_http_status(304)
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