diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-20 14:22:11 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-20 14:22:11 +0000 |
commit | 0c872e02b2c822e3397515ec324051ff540f0cd5 (patch) | |
tree | ce2fb6ce7030e4dad0f4118d21ab6453e5938cdd /spec/services/issues/close_service_spec.rb | |
parent | f7e05a6853b12f02911494c4b3fe53d9540d74fc (diff) | |
download | gitlab-ce-0c872e02b2c822e3397515ec324051ff540f0cd5.tar.gz |
Add latest changes from gitlab-org/gitlab@15-7-stable-eev15.7.0-rc42
Diffstat (limited to 'spec/services/issues/close_service_spec.rb')
-rw-r--r-- | spec/services/issues/close_service_spec.rb | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/spec/services/issues/close_service_spec.rb b/spec/services/issues/close_service_spec.rb index ef92b6984d5..e6ad755f911 100644 --- a/spec/services/issues/close_service_spec.rb +++ b/spec/services/issues/close_service_spec.rb @@ -99,6 +99,14 @@ RSpec.describe Issues::CloseService do it_behaves_like 'an incident management tracked event', :incident_management_incident_closed + it_behaves_like 'Snowplow event tracking with RedisHLL context' do + let(:feature_flag_name) { :route_hll_to_snowplow_phase2 } + let(:namespace) { issue.namespace } + let(:category) { described_class.to_s } + let(:action) { 'incident_management_incident_closed' } + let(:label) { 'redis_hll_counters.incident_management.incident_management_total_unique_counts_monthly' } + end + it 'creates a new escalation resolved escalation status', :aggregate_failures do expect { service.execute(issue) }.to change { IncidentManagement::IssuableEscalationStatus.where(issue: issue).count }.by(1) @@ -346,31 +354,26 @@ RSpec.describe Issues::CloseService do context 'when there is an associated Alert Management Alert' do context 'when alert can be resolved' do - let!(:alert) { create(:alert_management_alert, issue: issue, project: project) } - it 'resolves an alert and sends a system note' do - expect_any_instance_of(SystemNoteService) do |notes_service| - expect(notes_service).to receive(:change_alert_status).with( - alert, - current_user, - " by closing issue #{issue.to_reference(project)}" - ) - end + alert = create(:alert_management_alert, issue: issue, project: project) + + expect(SystemNoteService).to receive(:change_alert_status) + .with(alert, User.alert_bot, " because #{user.to_reference} closed incident #{issue.to_reference(project)}") close_issue - expect(alert.reload.resolved?).to eq(true) + expect(alert.reload).to be_resolved end end context 'when alert cannot be resolved' do - let!(:alert) { create(:alert_management_alert, :with_validation_errors, issue: issue, project: project) } - before do allow(Gitlab::AppLogger).to receive(:warn).and_call_original end it 'writes a warning into the log' do + alert = create(:alert_management_alert, :with_validation_errors, issue: issue, project: project) + close_issue expect(Gitlab::AppLogger).to have_received(:warn).with( @@ -383,6 +386,23 @@ RSpec.describe Issues::CloseService do end end + context 'when there are several associated Alert Management Alerts' do + context 'when alerts can be resolved' do + it 'resolves an alert and sends a system note', :aggregate_failures do + alerts = create_list(:alert_management_alert, 2, issue: issue, project: project) + + alerts.each do |alert| + expect(SystemNoteService).to receive(:change_alert_status) + .with(alert, User.alert_bot, " because #{user.to_reference} closed incident #{issue.to_reference(project)}") + end + + close_issue + + expect(alerts.map(&:reload)).to all(be_resolved) + end + end + end + it 'deletes milestone issue counters cache' do issue.update!(milestone: create(:milestone, project: project)) |