diff options
author | Rémy Coutable <remy@rymai.me> | 2016-04-13 15:05:21 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-04-13 15:05:21 +0000 |
commit | 94e130cec30a8cfa6687d254e1cabce568a22634 (patch) | |
tree | f92966b9197edc7360c94de457341c3f086e7a42 /spec/requests/api | |
parent | eebd7533ea780dade5e953b05c83c7b87f4bbf6f (diff) | |
parent | 54231aa4e036179d035ddd3641bc15a5b31883f2 (diff) | |
download | gitlab-ce-94e130cec30a8cfa6687d254e1cabce568a22634.tar.gz |
Merge branch 'api-star-project' into 'master'
API: Star and unstar a project
Add two new endpoints `POST /projects/:id/star` and `POST /projects/:id/unstar` to star and unstar a project.
* Closes #12739
See merge request !3578
Diffstat (limited to 'spec/requests/api')
-rw-r--r-- | spec/requests/api/projects_spec.rb | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index be2034e0f39..fccd08bd6da 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -1020,6 +1020,54 @@ describe API::API, api: true do end end + describe 'POST /projects/:id/star' do + context 'on an unstarred project' do + it 'stars the project' do + expect { post api("/projects/#{project.id}/star", user) }.to change { project.reload.star_count }.by(1) + + expect(response.status).to eq(201) + expect(json_response['star_count']).to eq(1) + end + end + + context 'on a starred project' do + before do + user.toggle_star(project) + project.reload + end + + it 'does not modify the star count' do + expect { post api("/projects/#{project.id}/star", user) }.not_to change { project.reload.star_count } + + expect(response.status).to eq(304) + end + end + end + + describe 'DELETE /projects/:id/star' do + context 'on a starred project' do + before do + user.toggle_star(project) + project.reload + end + + it 'unstars the project' do + expect { delete api("/projects/#{project.id}/star", user) }.to change { project.reload.star_count }.by(-1) + + expect(response.status).to eq(200) + 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(response.status).to eq(304) + end + end + end + describe 'DELETE /projects/:id' do context 'when authenticated as user' do it 'should remove project' do |