diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 12:16:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 12:16:11 +0300 |
commit | edaa33dee2ff2f7ea3fac488d41558eb5f86d68c (patch) | |
tree | 11f143effbfeba52329fb7afbd05e6e2a3790241 /spec/services/alert_management/alerts/update_service_spec.rb | |
parent | d8a5691316400a0f7ec4f83832698f1988eb27c1 (diff) |
Add latest changes from gitlab-org/gitlab@14-7-stable-eev14.7.0-rc42
Diffstat (limited to 'spec/services/alert_management/alerts/update_service_spec.rb')
-rw-r--r-- | spec/services/alert_management/alerts/update_service_spec.rb | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/spec/services/alert_management/alerts/update_service_spec.rb b/spec/services/alert_management/alerts/update_service_spec.rb index 4b47efca9ed..35697ac79a0 100644 --- a/spec/services/alert_management/alerts/update_service_spec.rb +++ b/spec/services/alert_management/alerts/update_service_spec.rb @@ -235,6 +235,59 @@ RSpec.describe AlertManagement::Alerts::UpdateService do it_behaves_like 'adds a system note' end + + context 'with an associated issue' do + let_it_be(:issue, reload: true) { create(:issue, project: project) } + + before do + alert.update!(issue: issue) + end + + shared_examples 'does not sync with the incident status' do + specify do + expect(::Issues::UpdateService).not_to receive(:new) + expect { response }.to change { alert.acknowledged? }.to(true) + end + end + + it_behaves_like 'does not sync with the incident status' + + context 'when the issue is an incident' do + before do + issue.update!(issue_type: Issue.issue_types[:incident]) + end + + it_behaves_like 'does not sync with the incident status' + + context 'when the incident has an escalation status' do + let_it_be(:escalation_status, reload: true) { create(:incident_management_issuable_escalation_status, issue: issue) } + + it 'updates the incident escalation status with the new alert status' do + expect(::Issues::UpdateService).to receive(:new).once.and_call_original + expect(described_class).to receive(:new).once.and_call_original + + expect { response }.to change { escalation_status.reload.acknowledged? }.to(true) + .and change { alert.reload.acknowledged? }.to(true) + end + + context 'when the statuses match' do + before do + escalation_status.update!(status_event: :acknowledge) + end + + it_behaves_like 'does not sync with the incident status' + end + + context 'when feature flag is disabled' do + before do + stub_feature_flags(incident_escalations: false) + end + + it_behaves_like 'does not sync with the incident status' + end + end + end + end end end end |