diff options
author | Mayra Cabrera <mcabrera@gitlab.com> | 2019-03-12 13:15:33 +0300 |
---|---|---|
committer | Kamil TrzciĆski <ayufan@ayufan.eu> | 2019-03-12 13:15:33 +0300 |
commit | 7e9348f3594ee158dfd4aaa9e03e5bb5dd36aead (patch) | |
tree | 74e03ba375331ab619a766d5d2a3c12aaa267095 /spec/helpers/auto_devops_helper_spec.rb | |
parent | db37b5a4c8d408e1bce0843162c609dcb1781188 (diff) |
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/helpers/auto_devops_helper_spec.rb')
-rw-r--r-- | spec/helpers/auto_devops_helper_spec.rb | 138 |
1 files changed, 135 insertions, 3 deletions
diff --git a/spec/helpers/auto_devops_helper_spec.rb b/spec/helpers/auto_devops_helper_spec.rb index 223e562238d..d2540696b17 100644 --- a/spec/helpers/auto_devops_helper_spec.rb +++ b/spec/helpers/auto_devops_helper_spec.rb @@ -29,11 +29,11 @@ describe AutoDevopsHelper do end context 'when the banner is disabled by feature flag' do - it 'allows the feature flag to disable' do + before do Feature.get(:auto_devops_banner_disabled).enable - - expect(subject).to be(false) end + + it { is_expected.to be_falsy } end context 'when dismissed' do @@ -90,4 +90,136 @@ describe AutoDevopsHelper do it { is_expected.to eq(false) } end end + + describe '#badge_for_auto_devops_scope' do + subject { helper.badge_for_auto_devops_scope(receiver) } + + context 'when receiver is a group' do + context 'when explicitly enabled' do + let(:receiver) { create(:group, :auto_devops_enabled) } + + it { is_expected.to eq('group enabled') } + end + + context 'when explicitly disabled' do + let(:receiver) { create(:group, :auto_devops_disabled) } + + it { is_expected.to be_nil } + end + + context 'when auto devops is implicitly enabled' do + let(:receiver) { create(:group) } + + context 'by instance' do + before do + stub_application_setting(auto_devops_enabled: true) + end + + it { is_expected.to eq('instance enabled') } + end + + context 'with groups', :nested_groups do + before do + receiver.update(parent: parent) + end + + context 'when auto devops is enabled on parent' do + let(:parent) { create(:group, :auto_devops_enabled) } + + it { is_expected.to eq('group enabled') } + end + + context 'when auto devops is enabled on parent group' do + let(:root_parent) { create(:group, :auto_devops_enabled) } + let(:parent) { create(:group, parent: root_parent) } + + it { is_expected.to eq('group enabled') } + end + + context 'when auto devops disabled set on parent group' do + let(:root_parent) { create(:group, :auto_devops_disabled) } + let(:parent) { create(:group, parent: root_parent) } + + it { is_expected.to be_nil } + end + end + end + end + + context 'when receiver is a project' do + context 'when auto devops is enabled at project level' do + let(:receiver) { create(:project, :auto_devops) } + + it { is_expected.to be_nil } + end + + context 'when auto devops is disabled at project level' do + let(:receiver) { create(:project, :auto_devops_disabled) } + + it { is_expected.to be_nil } + end + + context 'when auto devops is implicitly enabled' do + let(:receiver) { create(:project) } + + context 'by instance' do + before do + stub_application_setting(auto_devops_enabled: true) + end + + it { is_expected.to eq('instance enabled') } + end + + context 'with groups', :nested_groups do + let(:receiver) { create(:project, :repository, namespace: group) } + + before do + stub_application_setting(auto_devops_enabled: false) + end + + context 'when auto devops is enabled on group level' do + let(:group) { create(:group, :auto_devops_enabled) } + + it { is_expected.to eq('group enabled') } + end + + context 'when auto devops is enabled on root group' do + let(:root_parent) { create(:group, :auto_devops_enabled) } + let(:group) { create(:group, parent: root_parent) } + + it { is_expected.to eq('group enabled') } + end + end + end + + context 'when auto devops is implicitly disabled' do + let(:receiver) { create(:project) } + + context 'by instance' do + before do + stub_application_setting(auto_devops_enabled: false) + end + + it { is_expected.to be_nil } + end + + context 'with groups', :nested_groups do + let(:receiver) { create(:project, :repository, namespace: group) } + + context 'when auto devops is disabled on group level' do + let(:group) { create(:group, :auto_devops_disabled) } + + it { is_expected.to be_nil } + end + + context 'when root group is enabled and parent disabled' do + let(:root_parent) { create(:group, :auto_devops_enabled) } + let(:group) { create(:group, :auto_devops_disabled, parent: root_parent) } + + it { is_expected.to be_nil } + end + end + end + end + end end |