diff options
author | Sean McGivern <sean@gitlab.com> | 2019-08-27 08:53:09 +0000 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2019-08-27 08:53:09 +0000 |
commit | a390f5ff052cfb9d214acbf1f4e78a830ba0e67b (patch) | |
tree | ca4dae64930e94f0b799700f3d98afa3303265c3 /spec | |
parent | 1c983571894355e6087b4c95b445e25d30e4ad3a (diff) | |
parent | 1819dbd4d1c06489325f4223222b499a59b78e37 (diff) | |
download | gitlab-ce-a390f5ff052cfb9d214acbf1f4e78a830ba0e67b.tar.gz |
Merge branch '57657-promote-label-to-group-label-via-api-endpoint' into 'master'
Promote Label to Group Label via API endpoint
Closes #57657
See merge request gitlab-org/gitlab-ce!25218
Diffstat (limited to 'spec')
-rw-r--r-- | spec/requests/api/labels_spec.rb | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/spec/requests/api/labels_spec.rb b/spec/requests/api/labels_spec.rb index f6640fe41d0..9aef67e28a7 100644 --- a/spec/requests/api/labels_spec.rb +++ b/spec/requests/api/labels_spec.rb @@ -473,6 +473,55 @@ describe API::Labels do end end + describe 'PUT /projects/:id/labels/promote' do + let(:group) { create(:group) } + + before do + group.add_owner(user) + project.update!(group: group) + end + + it 'returns 200 if label is promoted' do + put api("/projects/#{project.id}/labels/promote", user), params: { name: label1.name } + + expect(response).to have_gitlab_http_status(200) + expect(json_response['name']).to eq(label1.name) + expect(json_response['color']).to eq(label1.color) + end + + it 'returns 200 if group label already exists' do + create(:group_label, title: label1.name, group: group) + + expect { put api("/projects/#{project.id}/labels/promote", user), params: { name: label1.name } } + .to change(project.labels, :count).by(-1) + .and change(group.labels, :count).by(0) + + expect(response).to have_gitlab_http_status(200) + end + + it 'returns 403 if guest promotes label' do + guest = create(:user) + project.add_guest(guest) + + put api("/projects/#{project.id}/labels/promote", guest), params: { name: label1.name } + + expect(response).to have_gitlab_http_status(403) + end + + it 'returns 404 if label does not exist' do + put api("/projects/#{project.id}/labels/promote", user), params: { name: 'unknown' } + + expect(response).to have_gitlab_http_status(404) + end + + it 'returns 400 if no label name given' do + put api("/projects/#{project.id}/labels/promote", user) + + expect(response).to have_gitlab_http_status(400) + expect(json_response['error']).to eq('name is missing') + end + end + describe "POST /projects/:id/labels/:label_id/subscribe" do context "when label_id is a label title" do it "subscribes to the label" do |