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/controllers | |
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/controllers')
-rw-r--r-- | spec/controllers/groups/settings/ci_cd_controller_spec.rb | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/spec/controllers/groups/settings/ci_cd_controller_spec.rb b/spec/controllers/groups/settings/ci_cd_controller_spec.rb index 40673d10b91..15eb0a442a6 100644 --- a/spec/controllers/groups/settings/ci_cd_controller_spec.rb +++ b/spec/controllers/groups/settings/ci_cd_controller_spec.rb @@ -66,4 +66,77 @@ describe Groups::Settings::CiCdController do end end end + + describe 'PATCH #update_auto_devops' do + let(:auto_devops_param) { '1' } + + subject do + patch :update_auto_devops, params: { + group_id: group, + group: { auto_devops_enabled: auto_devops_param } + } + end + + context 'when user does not have enough permission' do + before do + group.add_maintainer(user) + end + + it { is_expected.to have_gitlab_http_status(404) } + end + + context 'when user has enough privileges' do + before do + group.add_owner(user) + end + + it { is_expected.to redirect_to(group_settings_ci_cd_path) } + + context 'when service execution went wrong' do + before do + allow_any_instance_of(Groups::AutoDevopsService).to receive(:execute).and_return(false) + allow_any_instance_of(Group).to receive_message_chain(:errors, :full_messages) + .and_return(['Error 1']) + + subject + end + + it 'returns a flash alert' do + expect(response).to set_flash[:alert] + .to eq("There was a problem updating Auto DevOps pipeline: [\"Error 1\"].") + end + end + + context 'when service execution was successful' do + it 'returns a flash notice' do + subject + + expect(response).to set_flash[:notice] + .to eq('Auto DevOps pipeline was updated for the group') + end + end + + context 'when changing auto devops value' do + before do + subject + + group.reload + end + + context 'when explicitly enabling auto devops' do + it 'should update group attribute' do + expect(group.auto_devops_enabled).to eq(true) + end + end + + context 'when explicitly disabling auto devops' do + let(:auto_devops_param) { '0' } + + it 'should update group attribute' do + expect(group.auto_devops_enabled).to eq(false) + end + end + end + end + end end |