2019-04-15 06:17:05 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-05-03 14:51:55 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Groups::VariablesController do
|
2019-04-09 11:38:58 -04:00
|
|
|
include ExternalAuthorizationServiceHelpers
|
|
|
|
|
2017-05-03 14:51:55 -04:00
|
|
|
let(:group) { create(:group) }
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
2018-07-11 10:36:08 -04:00
|
|
|
group.add_maintainer(user)
|
2017-05-03 14:51:55 -04:00
|
|
|
end
|
|
|
|
|
2018-01-29 12:54:16 -05:00
|
|
|
describe 'GET #show' do
|
|
|
|
let!(:variable) { create(:ci_group_variable, group: group) }
|
|
|
|
|
|
|
|
subject do
|
2018-12-17 17:52:17 -05:00
|
|
|
get :show, params: { group_id: group }, format: :json
|
2018-01-29 12:54:16 -05:00
|
|
|
end
|
|
|
|
|
2018-02-02 13:35:00 -05:00
|
|
|
include_examples 'GET #show lists all variables'
|
2018-01-29 12:54:16 -05:00
|
|
|
end
|
|
|
|
|
2018-02-02 13:35:00 -05:00
|
|
|
describe 'PATCH #update' do
|
2018-01-23 13:24:55 -05:00
|
|
|
let!(:variable) { create(:ci_group_variable, group: group) }
|
2018-02-02 13:35:00 -05:00
|
|
|
let(:owner) { group }
|
2018-02-02 12:54:13 -05:00
|
|
|
|
|
|
|
subject do
|
|
|
|
patch :update,
|
2018-12-17 17:52:17 -05:00
|
|
|
params: {
|
|
|
|
group_id: group,
|
|
|
|
variables_attributes: variables_attributes
|
|
|
|
},
|
2018-02-02 12:54:13 -05:00
|
|
|
format: :json
|
|
|
|
end
|
|
|
|
|
2018-02-02 13:35:00 -05:00
|
|
|
include_examples 'PATCH #update updates variables'
|
2018-01-23 13:24:55 -05:00
|
|
|
end
|
2019-04-09 11:38:58 -04:00
|
|
|
|
|
|
|
context 'with external authorization enabled' do
|
|
|
|
before do
|
|
|
|
enable_external_authorization_service_check
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'GET #show' do
|
|
|
|
let!(:variable) { create(:ci_group_variable, group: group) }
|
|
|
|
|
|
|
|
it 'is successful' do
|
|
|
|
get :show, params: { group_id: group }, format: :json
|
|
|
|
|
2020-02-06 04:09:06 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:ok)
|
2019-04-09 11:38:58 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'PATCH #update' do
|
|
|
|
let!(:variable) { create(:ci_group_variable, group: group) }
|
|
|
|
let(:owner) { group }
|
|
|
|
|
|
|
|
it 'is successful' do
|
|
|
|
patch :update,
|
|
|
|
params: {
|
|
|
|
group_id: group,
|
|
|
|
variables_attributes: [{ id: variable.id, key: 'hello' }]
|
|
|
|
},
|
|
|
|
format: :json
|
|
|
|
|
2020-02-06 04:09:06 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:ok)
|
2019-04-09 11:38:58 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-05-03 14:51:55 -04:00
|
|
|
end
|