2018-08-26 04:26:02 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-08-24 03:35:27 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe API::GroupLabels do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:group) { create(:group) }
|
2019-09-26 14:06:29 -04:00
|
|
|
let(:subgroup) { create(:group, parent: group) }
|
2018-08-24 03:35:27 -04:00
|
|
|
let!(:group_member) { create(:group_member, group: group, user: user) }
|
2019-09-26 14:06:29 -04:00
|
|
|
let!(:group_label1) { create(:group_label, title: 'feature', group: group) }
|
|
|
|
let!(:group_label2) { create(:group_label, title: 'bug', group: group) }
|
|
|
|
let!(:subgroup_label) { create(:group_label, title: 'support', group: subgroup) }
|
2018-08-24 03:35:27 -04:00
|
|
|
|
|
|
|
describe 'GET :id/labels' do
|
|
|
|
it 'returns all available labels for the group' do
|
|
|
|
get api("/groups/#{group.id}/labels", user)
|
|
|
|
|
2020-02-25 07:08:48 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:ok)
|
2018-08-24 03:35:27 -04:00
|
|
|
expect(response).to include_pagination_headers
|
|
|
|
expect(json_response).to be_an Array
|
2019-08-06 12:27:46 -04:00
|
|
|
expect(json_response).to all(match_schema('public_api/v4/labels/label'))
|
2018-08-24 03:35:27 -04:00
|
|
|
expect(json_response.size).to eq(2)
|
2018-09-08 04:36:45 -04:00
|
|
|
expect(json_response.map {|r| r['name'] }).to contain_exactly('feature', 'bug')
|
2018-08-24 03:35:27 -04:00
|
|
|
end
|
2019-08-06 12:27:46 -04:00
|
|
|
|
|
|
|
context 'when the with_counts parameter is set' do
|
|
|
|
it 'includes counts in the response' do
|
|
|
|
get api("/groups/#{group.id}/labels", user), params: { with_counts: true }
|
|
|
|
|
2020-02-25 07:08:48 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:ok)
|
2019-08-06 12:27:46 -04:00
|
|
|
expect(response).to include_pagination_headers
|
|
|
|
expect(json_response).to be_an Array
|
|
|
|
expect(json_response).to all(match_schema('public_api/v4/labels/label_with_counts'))
|
|
|
|
expect(json_response.size).to eq(2)
|
|
|
|
expect(json_response.map { |r| r['open_issues_count'] }).to contain_exactly(0, 0)
|
|
|
|
end
|
|
|
|
end
|
2018-08-24 03:35:27 -04:00
|
|
|
end
|
|
|
|
|
2019-09-26 14:06:29 -04:00
|
|
|
describe 'GET :subgroup_id/labels' do
|
|
|
|
context 'when the include_ancestor_groups parameter is not set' do
|
|
|
|
it 'returns all available labels for the group and ancestor groups' do
|
|
|
|
get api("/groups/#{subgroup.id}/labels", user)
|
|
|
|
|
2020-02-25 07:08:48 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:ok)
|
2019-09-26 14:06:29 -04:00
|
|
|
expect(response).to include_pagination_headers
|
|
|
|
expect(json_response).to be_an Array
|
|
|
|
expect(json_response).to all(match_schema('public_api/v4/labels/label'))
|
|
|
|
expect(json_response.size).to eq(3)
|
|
|
|
expect(json_response.map {|r| r['name'] }).to contain_exactly('feature', 'bug', 'support')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the include_ancestor_groups parameter is set to false' do
|
|
|
|
it 'returns all available labels for the group but not for ancestor groups' do
|
|
|
|
get api("/groups/#{subgroup.id}/labels", user), params: { include_ancestor_groups: false }
|
|
|
|
|
2020-02-25 07:08:48 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:ok)
|
2019-09-26 14:06:29 -04:00
|
|
|
expect(response).to include_pagination_headers
|
|
|
|
expect(json_response).to be_an Array
|
|
|
|
expect(json_response).to all(match_schema('public_api/v4/labels/label'))
|
|
|
|
expect(json_response.size).to eq(1)
|
|
|
|
expect(json_response.map {|r| r['name'] }).to contain_exactly('support')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-09-27 11:06:16 -04:00
|
|
|
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)
|
|
|
|
|
2020-02-25 07:08:48 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:ok)
|
2019-09-27 11:06:16 -04:00
|
|
|
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
|
|
|
|
|
2018-08-24 03:35:27 -04:00
|
|
|
describe 'POST /groups/:id/labels' do
|
2018-09-08 04:36:45 -04:00
|
|
|
it 'returns created label when all params are given' do
|
2018-08-24 03:35:27 -04:00
|
|
|
post api("/groups/#{group.id}/labels", user),
|
2019-01-06 12:56:02 -05:00
|
|
|
params: {
|
|
|
|
name: 'Foo',
|
|
|
|
color: '#FFAABB',
|
|
|
|
description: 'test'
|
|
|
|
}
|
2018-08-24 03:35:27 -04:00
|
|
|
|
2020-02-25 07:08:48 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:created)
|
2018-08-24 03:35:27 -04:00
|
|
|
expect(json_response['name']).to eq('Foo')
|
|
|
|
expect(json_response['color']).to eq('#FFAABB')
|
|
|
|
expect(json_response['description']).to eq('test')
|
|
|
|
end
|
|
|
|
|
2018-09-08 04:36:45 -04:00
|
|
|
it 'returns created label when only required params are given' do
|
2018-08-24 03:35:27 -04:00
|
|
|
post api("/groups/#{group.id}/labels", user),
|
2019-01-06 12:56:02 -05:00
|
|
|
params: {
|
|
|
|
name: 'Foo & Bar',
|
|
|
|
color: '#FFAABB'
|
|
|
|
}
|
2018-08-24 03:35:27 -04:00
|
|
|
|
2020-03-31 17:08:05 -04:00
|
|
|
expect(response).to have_gitlab_http_status(:created)
|
2018-08-24 03:35:27 -04:00
|
|
|
expect(json_response['name']).to eq('Foo & Bar')
|
|
|
|
expect(json_response['color']).to eq('#FFAABB')
|
|
|
|
expect(json_response['description']).to be_nil
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns a 400 bad request if name not given' do
|
2019-01-06 12:56:02 -05:00
|
|
|
post api("/groups/#{group.id}/labels", user), params: { color: '#FFAABB' }
|
2018-08-24 03:35:27 -04:00
|
|
|
|
2020-02-25 07:08:48 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:bad_request)
|
2018-08-24 03:35:27 -04:00
|
|
|
end
|
|
|
|
|
2018-09-08 04:36:45 -04:00
|
|
|
it 'returns a 400 bad request if color is not given' do
|
2019-01-06 12:56:02 -05:00
|
|
|
post api("/groups/#{group.id}/labels", user), params: { name: 'Foobar' }
|
2018-08-24 03:35:27 -04:00
|
|
|
|
2020-02-25 07:08:48 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:bad_request)
|
2018-08-24 03:35:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns 409 if label already exists' do
|
|
|
|
post api("/groups/#{group.id}/labels", user),
|
2019-01-06 12:56:02 -05:00
|
|
|
params: {
|
2019-09-26 14:06:29 -04:00
|
|
|
name: group_label1.name,
|
2019-01-06 12:56:02 -05:00
|
|
|
color: '#FFAABB'
|
|
|
|
}
|
2018-08-24 03:35:27 -04:00
|
|
|
|
2020-02-25 07:08:48 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:conflict)
|
2018-08-24 03:35:27 -04:00
|
|
|
expect(json_response['message']).to eq('Label already exists')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-09-27 11:06:16 -04:00
|
|
|
describe 'DELETE /groups/:id/labels (deprecated)' do
|
2018-08-24 03:35:27 -04:00
|
|
|
it 'returns 204 for existing label' do
|
2019-09-26 14:06:29 -04:00
|
|
|
delete api("/groups/#{group.id}/labels", user), params: { name: group_label1.name }
|
2018-08-24 03:35:27 -04:00
|
|
|
|
2020-02-25 07:08:48 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:no_content)
|
2018-08-24 03:35:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns 404 for non existing label' do
|
2019-09-26 14:06:29 -04:00
|
|
|
delete api("/groups/#{group.id}/labels", user), params: { name: 'not_exists' }
|
2018-08-24 03:35:27 -04:00
|
|
|
|
2020-02-25 07:08:48 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:not_found)
|
2018-08-24 03:35:27 -04:00
|
|
|
expect(json_response['message']).to eq('404 Label Not Found')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns 400 for wrong parameters' do
|
|
|
|
delete api("/groups/#{group.id}/labels", user)
|
|
|
|
|
2020-02-25 07:08:48 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:bad_request)
|
2018-08-24 03:35:27 -04:00
|
|
|
end
|
|
|
|
|
2019-07-24 05:20:54 -04:00
|
|
|
it "does not delete parent's group labels" do
|
2018-09-08 04:36:45 -04:00
|
|
|
subgroup = create(:group, parent: group)
|
|
|
|
subgroup_label = create(:group_label, title: 'feature', group: subgroup)
|
|
|
|
|
2019-01-06 12:56:02 -05:00
|
|
|
delete api("/groups/#{subgroup.id}/labels", user), params: { name: subgroup_label.name }
|
2018-09-08 04:36:45 -04:00
|
|
|
|
2020-02-25 07:08:48 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:no_content)
|
2018-09-08 04:36:45 -04:00
|
|
|
expect(subgroup.labels.size).to eq(0)
|
2019-09-26 14:06:29 -04:00
|
|
|
expect(group.labels).to include(group_label1)
|
2018-09-08 04:36:45 -04:00
|
|
|
end
|
|
|
|
|
2018-08-24 03:35:27 -04:00
|
|
|
it_behaves_like '412 response' do
|
|
|
|
let(:request) { api("/groups/#{group.id}/labels", user) }
|
2019-09-26 14:06:29 -04:00
|
|
|
let(:params) { { name: group_label1.name } }
|
2018-08-24 03:35:27 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-09-27 11:06:16 -04:00
|
|
|
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)
|
|
|
|
|
2020-02-25 07:08:48 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:no_content)
|
2019-09-27 11:06:16 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns 404 for non existing label' do
|
|
|
|
delete api("/groups/#{group.id}/labels/not_exists", user)
|
|
|
|
|
2020-02-25 07:08:48 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:not_found)
|
2019-09-27 11:06:16 -04:00
|
|
|
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)
|
|
|
|
|
2020-02-25 07:08:48 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:no_content)
|
2019-09-27 11:06:16 -04:00
|
|
|
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
|
2018-08-24 03:35:27 -04:00
|
|
|
it 'returns 200 if name and colors and description are changed' do
|
|
|
|
put api("/groups/#{group.id}/labels", user),
|
2019-01-06 12:56:02 -05:00
|
|
|
params: {
|
2019-09-26 14:06:29 -04:00
|
|
|
name: group_label1.name,
|
2019-01-06 12:56:02 -05:00
|
|
|
new_name: 'New Label',
|
|
|
|
color: '#FFFFFF',
|
|
|
|
description: 'test'
|
|
|
|
}
|
2018-09-08 04:36:45 -04:00
|
|
|
|
2020-02-25 07:08:48 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:ok)
|
2018-08-24 03:35:27 -04:00
|
|
|
expect(json_response['name']).to eq('New Label')
|
|
|
|
expect(json_response['color']).to eq('#FFFFFF')
|
|
|
|
expect(json_response['description']).to eq('test')
|
|
|
|
end
|
|
|
|
|
2019-07-24 05:20:54 -04:00
|
|
|
it "does not update parent's group label" do
|
2018-09-08 04:36:45 -04:00
|
|
|
subgroup = create(:group, parent: group)
|
|
|
|
subgroup_label = create(:group_label, title: 'feature', group: subgroup)
|
|
|
|
|
|
|
|
put api("/groups/#{subgroup.id}/labels", user),
|
2019-01-06 12:56:02 -05:00
|
|
|
params: {
|
|
|
|
name: subgroup_label.name,
|
|
|
|
new_name: 'New Label'
|
|
|
|
}
|
2018-09-08 04:36:45 -04:00
|
|
|
|
2020-02-25 07:08:48 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:ok)
|
2018-09-08 04:36:45 -04:00
|
|
|
expect(subgroup.labels[0].name).to eq('New Label')
|
2019-09-26 14:06:29 -04:00
|
|
|
expect(group_label1.name).to eq('feature')
|
2018-09-08 04:36:45 -04:00
|
|
|
end
|
|
|
|
|
2018-08-24 03:35:27 -04:00
|
|
|
it 'returns 404 if label does not exist' do
|
|
|
|
put api("/groups/#{group.id}/labels", user),
|
2019-01-06 12:56:02 -05:00
|
|
|
params: {
|
2019-09-26 14:06:29 -04:00
|
|
|
name: 'not_exists',
|
2019-01-06 12:56:02 -05:00
|
|
|
new_name: 'label3'
|
|
|
|
}
|
2018-08-24 03:35:27 -04:00
|
|
|
|
2020-02-25 07:08:48 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:not_found)
|
2018-08-24 03:35:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns 400 if no label name given' do
|
2019-09-26 14:06:29 -04:00
|
|
|
put api("/groups/#{group.id}/labels", user), params: { new_name: group_label1.name }
|
2018-08-24 03:35:27 -04:00
|
|
|
|
2020-02-25 07:08:48 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:bad_request)
|
2019-09-27 11:06:16 -04:00
|
|
|
expect(json_response['error']).to eq('label_id, name are missing, exactly one parameter must be provided')
|
2018-08-24 03:35:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns 400 if no new parameters given' do
|
2019-09-26 14:06:29 -04:00
|
|
|
put api("/groups/#{group.id}/labels", user), params: { name: group_label1.name }
|
2018-08-24 03:35:27 -04:00
|
|
|
|
2020-02-25 07:08:48 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:bad_request)
|
2018-08-24 03:35:27 -04:00
|
|
|
expect(json_response['error']).to eq('new_name, color, description are missing, '\
|
|
|
|
'at least one parameter must be provided')
|
|
|
|
end
|
|
|
|
end
|
2018-08-25 16:29:27 -04:00
|
|
|
|
2019-09-27 11:06:16 -04:00
|
|
|
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'
|
|
|
|
}
|
|
|
|
|
2020-02-25 07:08:48 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:ok)
|
2019-09-27 11:06:16 -04:00
|
|
|
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'
|
|
|
|
}
|
|
|
|
|
2020-02-25 07:08:48 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:ok)
|
2019-09-27 11:06:16 -04:00
|
|
|
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'
|
|
|
|
}
|
|
|
|
|
2020-02-25 07:08:48 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:not_found)
|
2019-09-27 11:06:16 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns 400 if no new parameters given' do
|
|
|
|
put api("/groups/#{group.id}/labels/#{group_label1.name}", user)
|
|
|
|
|
2020-02-25 07:08:48 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:bad_request)
|
2019-09-27 11:06:16 -04:00
|
|
|
expect(json_response['error']).to eq('new_name, color, description are missing, '\
|
|
|
|
'at least one parameter must be provided')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-08-25 16:29:27 -04:00
|
|
|
describe 'POST /groups/:id/labels/:label_id/subscribe' do
|
|
|
|
context 'when label_id is a label title' do
|
|
|
|
it 'subscribes to the label' do
|
2019-09-26 14:06:29 -04:00
|
|
|
post api("/groups/#{group.id}/labels/#{group_label1.title}/subscribe", user)
|
2018-08-25 16:29:27 -04:00
|
|
|
|
2020-02-25 07:08:48 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:created)
|
2019-09-26 14:06:29 -04:00
|
|
|
expect(json_response['name']).to eq(group_label1.title)
|
2018-08-25 16:29:27 -04:00
|
|
|
expect(json_response['subscribed']).to be_truthy
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when label_id is a label ID' do
|
|
|
|
it 'subscribes to the label' do
|
2019-09-26 14:06:29 -04:00
|
|
|
post api("/groups/#{group.id}/labels/#{group_label1.id}/subscribe", user)
|
2018-08-25 16:29:27 -04:00
|
|
|
|
2020-02-25 07:08:48 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:created)
|
2019-09-26 14:06:29 -04:00
|
|
|
expect(json_response['name']).to eq(group_label1.title)
|
2018-08-25 16:29:27 -04:00
|
|
|
expect(json_response['subscribed']).to be_truthy
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when user is already subscribed to label' do
|
|
|
|
before do
|
2019-09-26 14:06:29 -04:00
|
|
|
group_label1.subscribe(user)
|
2018-08-25 16:29:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns 304' do
|
2019-09-26 14:06:29 -04:00
|
|
|
post api("/groups/#{group.id}/labels/#{group_label1.id}/subscribe", user)
|
2018-08-25 16:29:27 -04:00
|
|
|
|
2020-02-25 07:08:48 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:not_modified)
|
2018-08-25 16:29:27 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when label ID is not found' do
|
|
|
|
it 'returns 404 error' do
|
2020-04-01 11:07:45 -04:00
|
|
|
post api("/groups/#{group.id}/labels/#{non_existing_record_id}/subscribe", user)
|
2018-08-25 16:29:27 -04:00
|
|
|
|
2020-02-25 07:08:48 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:not_found)
|
2018-08-25 16:29:27 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'POST /groups/:id/labels/:label_id/unsubscribe' do
|
|
|
|
before do
|
2019-09-26 14:06:29 -04:00
|
|
|
group_label1.subscribe(user)
|
2018-08-25 16:29:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when label_id is a label title' do
|
|
|
|
it 'unsubscribes from the label' do
|
2019-09-26 14:06:29 -04:00
|
|
|
post api("/groups/#{group.id}/labels/#{group_label1.title}/unsubscribe", user)
|
2018-08-25 16:29:27 -04:00
|
|
|
|
2020-02-25 07:08:48 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:created)
|
2019-09-26 14:06:29 -04:00
|
|
|
expect(json_response['name']).to eq(group_label1.title)
|
2018-08-25 16:29:27 -04:00
|
|
|
expect(json_response['subscribed']).to be_falsey
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when label_id is a label ID' do
|
|
|
|
it 'unsubscribes from the label' do
|
2019-09-26 14:06:29 -04:00
|
|
|
post api("/groups/#{group.id}/labels/#{group_label1.id}/unsubscribe", user)
|
2018-08-25 16:29:27 -04:00
|
|
|
|
2020-02-25 07:08:48 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:created)
|
2019-09-26 14:06:29 -04:00
|
|
|
expect(json_response['name']).to eq(group_label1.title)
|
2018-08-25 16:29:27 -04:00
|
|
|
expect(json_response['subscribed']).to be_falsey
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when user is already unsubscribed from label' do
|
|
|
|
before do
|
2019-09-26 14:06:29 -04:00
|
|
|
group_label1.unsubscribe(user)
|
2018-08-25 16:29:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns 304' do
|
2019-09-26 14:06:29 -04:00
|
|
|
post api("/groups/#{group.id}/labels/#{group_label1.id}/unsubscribe", user)
|
2018-08-25 16:29:27 -04:00
|
|
|
|
2020-02-25 07:08:48 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:not_modified)
|
2018-08-25 16:29:27 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when label ID is not found' do
|
|
|
|
it 'returns 404 error' do
|
2020-04-01 11:07:45 -04:00
|
|
|
post api("/groups/#{group.id}/labels/#{non_existing_record_id}/unsubscribe", user)
|
2018-08-25 16:29:27 -04:00
|
|
|
|
2020-02-25 07:08:48 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:not_found)
|
2018-08-25 16:29:27 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|