Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-09-27 18:06:16 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-09-27 18:06:16 +0300
commit8320f7956d72986f5a7c850874fce4f8b5a8e015 (patch)
treec761b309cfff422609d47a17ac4d6a732c142f49 /spec/requests/api/group_labels_spec.rb
parent45482d5a2704da7fabe4ccf07f85d9be6e0a791a (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests/api/group_labels_spec.rb')
-rw-r--r--spec/requests/api/group_labels_spec.rb94
1 files changed, 91 insertions, 3 deletions
diff --git a/spec/requests/api/group_labels_spec.rb b/spec/requests/api/group_labels_spec.rb
index 3ac394b57c5..f7994b55efa 100644
--- a/spec/requests/api/group_labels_spec.rb
+++ b/spec/requests/api/group_labels_spec.rb
@@ -65,6 +65,17 @@ describe API::GroupLabels do
end
end
+ describe 'GET :id/labels/:label_id' do
+ it 'returns a single label for the group' do
+ get api("/groups/#{group.id}/labels/#{group_label1.name}", user)
+
+ expect(response).to have_gitlab_http_status(200)
+ expect(json_response['name']).to eq(group_label1.name)
+ expect(json_response['color']).to eq(group_label1.color)
+ expect(json_response['description']).to eq(group_label1.description)
+ end
+ end
+
describe 'POST /groups/:id/labels' do
it 'returns created label when all params are given' do
post api("/groups/#{group.id}/labels", user),
@@ -117,7 +128,7 @@ describe API::GroupLabels do
end
end
- describe 'DELETE /groups/:id/labels' do
+ describe 'DELETE /groups/:id/labels (deprecated)' do
it 'returns 204 for existing label' do
delete api("/groups/#{group.id}/labels", user), params: { name: group_label1.name }
@@ -154,7 +165,37 @@ describe API::GroupLabels do
end
end
- describe 'PUT /groups/:id/labels' do
+ describe 'DELETE /groups/:id/labels/:label_id' do
+ it 'returns 204 for existing label' do
+ delete api("/groups/#{group.id}/labels/#{group_label1.name}", user)
+
+ expect(response).to have_gitlab_http_status(204)
+ end
+
+ it 'returns 404 for non existing label' do
+ delete api("/groups/#{group.id}/labels/not_exists", user)
+
+ expect(response).to have_gitlab_http_status(404)
+ expect(json_response['message']).to eq('404 Label Not Found')
+ end
+
+ it "does not delete parent's group labels" do
+ subgroup = create(:group, parent: group)
+ subgroup_label = create(:group_label, title: 'feature', group: subgroup)
+
+ delete api("/groups/#{subgroup.id}/labels/#{subgroup_label.name}", user)
+
+ expect(response).to have_gitlab_http_status(204)
+ expect(subgroup.labels.size).to eq(0)
+ expect(group.labels).to include(group_label1)
+ end
+
+ it_behaves_like '412 response' do
+ let(:request) { api("/groups/#{group.id}/labels/#{group_label1.name}", user) }
+ end
+ end
+
+ describe 'PUT /groups/:id/labels (deprecated)' do
it 'returns 200 if name and colors and description are changed' do
put api("/groups/#{group.id}/labels", user),
params: {
@@ -199,7 +240,7 @@ describe API::GroupLabels do
put api("/groups/#{group.id}/labels", user), params: { new_name: group_label1.name }
expect(response).to have_gitlab_http_status(400)
- expect(json_response['error']).to eq('name is missing')
+ expect(json_response['error']).to eq('label_id, name are missing, exactly one parameter must be provided')
end
it 'returns 400 if no new parameters given' do
@@ -211,6 +252,53 @@ describe API::GroupLabels do
end
end
+ describe 'PUT /groups/:id/labels/:label_id' do
+ it 'returns 200 if name and colors and description are changed' do
+ put api("/groups/#{group.id}/labels/#{group_label1.name}", user),
+ params: {
+ new_name: 'New Label',
+ color: '#FFFFFF',
+ description: 'test'
+ }
+
+ expect(response).to have_gitlab_http_status(200)
+ expect(json_response['name']).to eq('New Label')
+ expect(json_response['color']).to eq('#FFFFFF')
+ expect(json_response['description']).to eq('test')
+ end
+
+ it "does not update parent's group label" do
+ subgroup = create(:group, parent: group)
+ subgroup_label = create(:group_label, title: 'feature', group: subgroup)
+
+ put api("/groups/#{subgroup.id}/labels/#{subgroup_label.name}", user),
+ params: {
+ new_name: 'New Label'
+ }
+
+ expect(response).to have_gitlab_http_status(200)
+ expect(subgroup.labels[0].name).to eq('New Label')
+ expect(group_label1.name).to eq('feature')
+ end
+
+ it 'returns 404 if label does not exist' do
+ put api("/groups/#{group.id}/labels/not_exists", user),
+ params: {
+ new_name: 'label3'
+ }
+
+ expect(response).to have_gitlab_http_status(404)
+ end
+
+ it 'returns 400 if no new parameters given' do
+ put api("/groups/#{group.id}/labels/#{group_label1.name}", user)
+
+ expect(response).to have_gitlab_http_status(400)
+ expect(json_response['error']).to eq('new_name, color, description are missing, '\
+ 'at least one parameter must be provided')
+ end
+ end
+
describe 'POST /groups/:id/labels/:label_id/subscribe' do
context 'when label_id is a label title' do
it 'subscribes to the label' do