diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 07:33:21 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 07:33:21 +0000 |
commit | 36a59d088eca61b834191dacea009677a96c052f (patch) | |
tree | e4f33972dab5d8ef79e3944a9f403035fceea43f /spec/services/alert_management | |
parent | a1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff) | |
download | gitlab-ce-36a59d088eca61b834191dacea009677a96c052f.tar.gz |
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
Diffstat (limited to 'spec/services/alert_management')
-rw-r--r-- | spec/services/alert_management/alerts/update_service_spec.rb | 45 |
1 files changed, 28 insertions, 17 deletions
diff --git a/spec/services/alert_management/alerts/update_service_spec.rb b/spec/services/alert_management/alerts/update_service_spec.rb index 882543fd701..f02607b8174 100644 --- a/spec/services/alert_management/alerts/update_service_spec.rb +++ b/spec/services/alert_management/alerts/update_service_spec.rb @@ -88,7 +88,7 @@ RSpec.describe AlertManagement::Alerts::UpdateService do it_behaves_like 'title update' end - context 'when alert is resolved and another existing open alert' do + context 'when alert is resolved and another existing unresolved alert' do let!(:alert) { create(:alert_management_alert, :resolved, project: project) } let!(:existing_alert) { create(:alert_management_alert, :triggered, project: project) } @@ -193,27 +193,38 @@ RSpec.describe AlertManagement::Alerts::UpdateService do end end - context 'with an opening status and existing open alert' do - let_it_be(:alert) { create(:alert_management_alert, :resolved, :with_fingerprint, project: project) } - let_it_be(:existing_alert) { create(:alert_management_alert, :triggered, fingerprint: alert.fingerprint, project: project) } - let_it_be(:url) { Gitlab::Routing.url_helpers.details_project_alert_management_path(project, existing_alert) } - let_it_be(:link) { ActionController::Base.helpers.link_to(_('alert'), url) } + context 'with existing unresolved alert' do + context 'with fingerprints' do + let_it_be(:existing_alert) { create(:alert_management_alert, :triggered, fingerprint: alert.fingerprint, project: project) } - let(:message) do - "An #{link} with the same fingerprint is already open. " \ - 'To change the status of this alert, resolve the linked alert.' - end + it 'does not query for existing alerts' do + expect(::AlertManagement::Alert).not_to receive(:find_unresolved_alert) - it_behaves_like 'does not add a todo' - it_behaves_like 'does not add a system note' + response + end - it 'has an informative message' do - expect(response).to be_error - expect(response.message).to eq(message) + context 'when status was resolved' do + let_it_be(:alert) { create(:alert_management_alert, :resolved, :with_fingerprint, project: project) } + let_it_be(:existing_alert) { create(:alert_management_alert, :triggered, fingerprint: alert.fingerprint, project: project) } + + let(:url) { Gitlab::Routing.url_helpers.details_project_alert_management_path(project, existing_alert) } + let(:link) { ActionController::Base.helpers.link_to(_('alert'), url) } + let(:message) do + "An #{link} with the same fingerprint is already open. " \ + 'To change the status of this alert, resolve the linked alert.' + end + + it_behaves_like 'does not add a todo' + it_behaves_like 'does not add a system note' + + it 'has an informative message' do + expect(response).to be_error + expect(response.message).to eq(message) + end + end end - context 'fingerprints are blank' do - let_it_be(:alert) { create(:alert_management_alert, :resolved, project: project, fingerprint: nil) } + context 'without fingerprints' do let_it_be(:existing_alert) { create(:alert_management_alert, :triggered, fingerprint: alert.fingerprint, project: project) } it 'successfully changes the status' do |