debian-mirror-gitlab/spec/controllers/groups/variables_controller_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

92 lines
2 KiB
Ruby
Raw Normal View History

2019-07-31 22:56:46 +05:30
# frozen_string_literal: true
2017-09-10 17:25:29 +05:30
require 'spec_helper'
2020-06-23 00:09:42 +05:30
RSpec.describe Groups::VariablesController do
2019-07-07 11:18:12 +05:30
include ExternalAuthorizationServiceHelpers
2021-03-05 16:19:46 +05:30
let_it_be(:group) { create(:group) }
let_it_be(:user) { create(:user) }
let_it_be(:variable) { create(:ci_group_variable, group: group) }
2021-04-29 21:17:54 +05:30
2021-03-05 16:19:46 +05:30
let(:access_level) { :owner }
2017-09-10 17:25:29 +05:30
before do
sign_in(user)
2022-08-13 15:12:31 +05:30
group.add_member(user, access_level)
2017-09-10 17:25:29 +05:30
end
2018-03-17 18:26:18 +05:30
describe 'GET #show' do
subject do
2019-02-15 15:39:39 +05:30
get :show, params: { group_id: group }, format: :json
2017-09-10 17:25:29 +05:30
end
2018-03-17 18:26:18 +05:30
include_examples 'GET #show lists all variables'
2021-03-05 16:19:46 +05:30
context 'when the user is a maintainer' do
let(:access_level) { :maintainer }
it 'returns not found response' do
subject
expect(response).to have_gitlab_http_status(:not_found)
end
end
2018-03-17 18:26:18 +05:30
end
2017-09-10 17:25:29 +05:30
2018-03-17 18:26:18 +05:30
describe 'PATCH #update' do
let(:owner) { group }
2017-09-10 17:25:29 +05:30
2018-03-17 18:26:18 +05:30
subject do
patch :update,
2019-02-15 15:39:39 +05:30
params: {
group_id: group,
variables_attributes: variables_attributes
},
2018-03-17 18:26:18 +05:30
format: :json
2017-09-10 17:25:29 +05:30
end
2018-03-17 18:26:18 +05:30
include_examples 'PATCH #update updates variables'
2021-03-05 16:19:46 +05:30
context 'when the user is a maintainer' do
let(:access_level) { :maintainer }
let(:variables_attributes) do
[{ id: variable.id, key: 'new_key' }]
end
it 'returns not found response' do
subject
expect(response).to have_gitlab_http_status(:not_found)
end
end
2017-09-10 17:25:29 +05:30
end
2019-07-07 11:18:12 +05:30
context 'with external authorization enabled' do
before do
enable_external_authorization_service_check
end
describe 'GET #show' do
it 'is successful' do
get :show, params: { group_id: group }, format: :json
2020-03-13 15:44:24 +05:30
expect(response).to have_gitlab_http_status(:ok)
2019-07-07 11:18:12 +05:30
end
end
describe 'PATCH #update' do
it 'is successful' do
patch :update,
params: {
group_id: group,
variables_attributes: [{ id: variable.id, key: 'hello' }]
},
format: :json
2020-03-13 15:44:24 +05:30
expect(response).to have_gitlab_http_status(:ok)
2019-07-07 11:18:12 +05:30
end
end
end
2017-09-10 17:25:29 +05:30
end