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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Client do
describe '.variables' do
before do
stub_get('/projects/3/variables', 'variables')
@variables = Gitlab.variables(3)
end
it 'gets the correct resource' do
expect(a_get('/projects/3/variables')).to have_been_made
end
it "returns an array of project's variables" do
expect(@variables).to be_a Gitlab::PaginatedResponse
expect(@variables.first.key).to eq('TEST_VARIABLE_1')
expect(@variables.first.value).to eq('TEST_1')
end
end
describe '.variable' do
before do
stub_get('/projects/3/variables/VARIABLE', 'variable')
@variable = Gitlab.variable(3, 'VARIABLE')
end
it 'gets the correct resource' do
expect(a_get('/projects/3/variables/VARIABLE')).to have_been_made
end
it 'returns information about a variable' do
expect(@variable.key).to eq('VARIABLE')
expect(@variable.value).to eq('the value')
end
end
describe '.create_variable' do
before do
stub_post('/projects/3/variables', 'variable', { masked: true })
@variable = Gitlab.create_variable(3, 'NEW_VARIABLE', 'new value')
end
it 'gets the correct resource' do
body = { key: 'NEW_VARIABLE', value: 'new value' }
expect(a_post('/projects/3/variables').with(body: body)).to have_been_made
end
it 'returns information about a new variable' do
expect(@variable.key).to eq('VARIABLE')
expect(@variable.value).to eq('the value')
end
end
describe '.update_variable' do
before do
stub_put('/projects/3/variables/UPD_VARIABLE', 'variable')
@variable = Gitlab.update_variable(3, 'UPD_VARIABLE', 'updated value')
end
it 'puts the correct resource' do
body = { value: 'updated value' }
expect(a_put('/projects/3/variables/UPD_VARIABLE').with(body: body)).to have_been_made
end
it 'returns information about an updated variable' do
expect(@variable.key).to eq('VARIABLE')
expect(@variable.value).to eq('the value')
end
end
describe '.remove_variable' do
before do
stub_delete('/projects/3/variables/DEL_VARIABLE', 'variable')
@variable = Gitlab.remove_variable(3, 'DEL_VARIABLE')
end
it 'gets the correct resource' do
expect(a_delete('/projects/3/variables/DEL_VARIABLE')).to have_been_made
end
it 'returns information about a deleted variable' do
expect(@variable.key).to eq('VARIABLE')
expect(@variable.value).to eq('the value')
end
end
describe '.group_variables' do
before do
stub_get('/groups/3/variables', 'variables')
@variables = Gitlab.group_variables(3)
end
it 'gets the correct resource' do
expect(a_get('/groups/3/variables')).to have_been_made
end
it "returns an array of group's variables" do
expect(@variables).to be_a Gitlab::PaginatedResponse
expect(@variables.first.key).to eq('TEST_VARIABLE_1')
expect(@variables.first.value).to eq('TEST_1')
end
end
describe '.group_variable' do
before do
stub_get('/groups/3/variables/VARIABLE', 'variable')
@variable = Gitlab.group_variable(3, 'VARIABLE')
end
it 'gets the correct resource' do
expect(a_get('/groups/3/variables/VARIABLE')).to have_been_made
end
it 'returns information about a variable' do
expect(@variable.key).to eq('VARIABLE')
expect(@variable.value).to eq('the value')
end
end
describe '.create_group_variable' do
before do
stub_post('/groups/3/variables', 'variable')
@variable = Gitlab.create_group_variable(3, 'NEW_VARIABLE', 'new value')
end
it 'gets the correct resource' do
body = { key: 'NEW_VARIABLE', value: 'new value' }
expect(a_post('/groups/3/variables').with(body: body)).to have_been_made
end
it 'returns information about a new variable' do
expect(@variable.key).to eq('VARIABLE')
expect(@variable.value).to eq('the value')
end
end
describe '.update_group_variable' do
before do
stub_put('/groups/3/variables/UPD_VARIABLE', 'variable')
@variable = Gitlab.update_group_variable(3, 'UPD_VARIABLE', 'updated value')
end
it 'puts the correct resource' do
body = { value: 'updated value' }
expect(a_put('/groups/3/variables/UPD_VARIABLE').with(body: body)).to have_been_made
end
it 'returns information about an updated variable' do
expect(@variable.key).to eq('VARIABLE')
expect(@variable.value).to eq('the value')
end
end
describe '.remove_group_variable' do
before do
stub_delete('/groups/3/variables/DEL_VARIABLE', 'variable')
@variable = Gitlab.remove_group_variable(3, 'DEL_VARIABLE')
end
it 'gets the correct resource' do
expect(a_delete('/groups/3/variables/DEL_VARIABLE')).to have_been_made
end
it 'returns information about a deleted variable' do
expect(@variable.key).to eq('VARIABLE')
expect(@variable.value).to eq('the value')
end
end
end
|