1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Client do
describe '.group_labels' do
before do
stub_get('/groups/3/labels', 'group_labels')
@labels = Gitlab.group_labels(3)
end
it 'gets the correct resource' do
expect(a_get('/groups/3/labels')).to have_been_made
end
it "returns a paginated response of group's labels" do
expect(@labels).to be_a Gitlab::PaginatedResponse
expect(@labels.first.name).to eq('Backlog')
end
end
describe '.create_group_label' do
before do
stub_post('/groups/3/labels', 'group_label')
@label = Gitlab.create_group_label(3, 'Backlog', '#DD10AA')
end
it 'gets the correct resource' do
expect(a_post('/groups/3/labels')
.with(body: { name: 'Backlog', color: '#DD10AA' })).to have_been_made
end
it 'returns information about a created label' do
expect(@label.name).to eq('Backlog')
expect(@label.color).to eq('#DD10AA')
end
end
describe '.edit_group_label' do
before do
stub_put('/groups/3/labels', 'group_label')
@label = Gitlab.edit_group_label(3, 'TODO', new_name: 'Backlog')
end
it 'gets the correct resource' do
expect(a_put('/groups/3/labels')
.with(body: { name: 'TODO', new_name: 'Backlog' })).to have_been_made
end
it 'returns information about an edited label' do
expect(@label.name).to eq('Backlog')
end
end
describe '.delete_group_label' do
before do
stub_delete('/groups/3/labels/Backlog', 'label')
@label = Gitlab.delete_group_label(3, 'Backlog')
end
it 'gets the correct resource' do
expect(a_delete('/groups/3/labels/Backlog')).to have_been_made
end
it 'returns information about a deleted snippet' do
expect(@label.name).to eq('Backlog')
end
end
describe '.subscribe_to_group_label' do
before do
stub_post('/groups/3/labels/Backlog/subscribe', 'group_label')
@label = Gitlab.subscribe_to_group_label(3, 'Backlog')
end
it 'gets the correct resource' do
expect(a_post('/groups/3/labels/Backlog/subscribe')).to have_been_made
end
it 'returns information about the label subscribed to' do
expect(@label.name).to eq('Backlog')
expect(@label.subscribed).to be(true)
end
end
describe '.unsubscribe_from_group_label' do
before do
stub_post('/groups/3/labels/Backlog/unsubscribe', 'group_label_unsubscribe')
@label = Gitlab.unsubscribe_from_group_label(3, 'Backlog')
end
it 'gets the correct resource' do
expect(a_post('/groups/3/labels/Backlog/unsubscribe')).to have_been_made
end
it 'returns information about the label subscribed to' do
expect(@label.name).to eq('Backlog')
expect(@label.subscribed).to be(false)
end
end
end
|