diff options
author | Mayra Cabrera <mcabrera@gitlab.com> | 2019-03-12 10:15:33 +0000 |
---|---|---|
committer | Kamil TrzciĆski <ayufan@ayufan.eu> | 2019-03-12 10:15:33 +0000 |
commit | 7e9348f3594ee158dfd4aaa9e03e5bb5dd36aead (patch) | |
tree | 74e03ba375331ab619a766d5d2a3c12aaa267095 /spec/services/groups | |
parent | db37b5a4c8d408e1bce0843162c609dcb1781188 (diff) | |
download | gitlab-ce-7e9348f3594ee158dfd4aaa9e03e5bb5dd36aead.tar.gz |
Enable/disable Auto DevOps at Group level
- Includes instance methods on Group model to detect when a group has
AutoDevOps explicitly/implicitly enabled/disabled.
- Includes migration to add a new column to namespaces table
- Add UI necessary modifications
- Add service and controller to update auto devops
related instances
- Updates project and groups auto devops badges
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/52447
Diffstat (limited to 'spec/services/groups')
-rw-r--r-- | spec/services/groups/auto_devops_service_spec.rb | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/spec/services/groups/auto_devops_service_spec.rb b/spec/services/groups/auto_devops_service_spec.rb new file mode 100644 index 00000000000..7f8ab517cef --- /dev/null +++ b/spec/services/groups/auto_devops_service_spec.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true +require 'spec_helper' + +describe Groups::AutoDevopsService, '#execute' do + set(:group) { create(:group) } + set(:user) { create(:user) } + let(:group_params) { { auto_devops_enabled: '0' } } + let(:service) { described_class.new(group, user, group_params) } + + context 'when user does not have enough privileges' do + it 'raises exception' do + group.add_developer(user) + + expect do + service.execute + end.to raise_exception(Gitlab::Access::AccessDeniedError) + end + end + + context 'when user has enough privileges' do + before do + group.add_owner(user) + end + + it 'updates group auto devops enabled accordingly' do + service.execute + + expect(group.auto_devops_enabled).to eq(false) + end + + context 'when group has projects' do + it 'reflects changes on projects' do + project_1 = create(:project, namespace: group) + + service.execute + + expect(project_1).not_to have_auto_devops_implicitly_enabled + end + end + + context 'when group has subgroups' do + it 'reflects changes on subgroups' do + subgroup_1 = create(:group, parent: group) + + service.execute + + expect(subgroup_1.auto_devops_enabled?).to eq(false) + end + + context 'when subgroups have projects', :nested_groups do + it 'reflects changes on projects' do + subgroup_1 = create(:group, parent: group) + project_1 = create(:project, namespace: subgroup_1) + + service.execute + + expect(project_1).not_to have_auto_devops_implicitly_enabled + end + end + end + end +end |