diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-16 00:08:49 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-16 00:08:49 +0300 |
commit | cf1d4237a4f226ba2deed26240544da0675a41e5 (patch) | |
tree | 926a71b9279659bc52db0187b463603934718bf2 /spec/controllers | |
parent | 0ac82f99553ce12009970a14c0afc02d1f6515bb (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/projects/settings/operations_controller_spec.rb | 70 |
1 files changed, 69 insertions, 1 deletions
diff --git a/spec/controllers/projects/settings/operations_controller_spec.rb b/spec/controllers/projects/settings/operations_controller_spec.rb index 0a2cc6f6aa5..62b906e8507 100644 --- a/spec/controllers/projects/settings/operations_controller_spec.rb +++ b/spec/controllers/projects/settings/operations_controller_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' describe Projects::Settings::OperationsController do let_it_be(:user) { create(:user) } - let_it_be(:project) { create(:project) } + let_it_be(:project, reload: true) { create(:project) } before do sign_in(user) @@ -121,6 +121,74 @@ describe Projects::Settings::OperationsController do end end + context 'incident management' do + describe 'GET #show' do + context 'with existing setting' do + let!(:incident_management_setting) do + create(:project_incident_management_setting, project: project) + end + + it 'loads existing setting' do + get :show, params: project_params(project) + + expect(controller.helpers.project_incident_management_setting) + .to eq(incident_management_setting) + end + end + + context 'without an existing setting' do + it 'builds a new setting' do + get :show, params: project_params(project) + + expect(controller.helpers.project_incident_management_setting).to be_new_record + end + end + end + + describe 'PATCH #update' do + let(:params) do + { + incident_management_setting_attributes: { + create_issue: 'false', + send_email: 'false', + issue_template_key: 'some-other-template' + } + } + end + + it_behaves_like 'PATCHable' + + context 'updating each incident management setting' do + let(:project) { create(:project) } + let(:new_incident_management_settings) { {} } + + before do + project.add_maintainer(user) + end + + shared_examples 'a gitlab tracking event' do |params, event_key| + it "creates a gitlab tracking event #{event_key}" do + new_incident_management_settings = params + + expect(Gitlab::Tracking).to receive(:event) + .with('IncidentManagement::Settings', event_key, kind_of(Hash)) + + patch :update, params: project_params(project, incident_management_setting_attributes: new_incident_management_settings) + + project.reload + end + end + + it_behaves_like 'a gitlab tracking event', { create_issue: '1' }, 'enabled_issue_auto_creation_on_alerts' + it_behaves_like 'a gitlab tracking event', { create_issue: '0' }, 'disabled_issue_auto_creation_on_alerts' + it_behaves_like 'a gitlab tracking event', { issue_template_key: 'template' }, 'enabled_issue_template_on_alerts' + it_behaves_like 'a gitlab tracking event', { issue_template_key: nil }, 'disabled_issue_template_on_alerts' + it_behaves_like 'a gitlab tracking event', { send_email: '1' }, 'enabled_sending_emails' + it_behaves_like 'a gitlab tracking event', { send_email: '0' }, 'disabled_sending_emails' + end + end + end + context 'error tracking' do describe 'GET #show' do context 'with existing setting' do |