summaryrefslogtreecommitdiff
path: root/spec/services/projects/alerting/notify_service_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/services/projects/alerting/notify_service_spec.rb')
-rw-r--r--spec/services/projects/alerting/notify_service_spec.rb30
1 files changed, 22 insertions, 8 deletions
diff --git a/spec/services/projects/alerting/notify_service_spec.rb b/spec/services/projects/alerting/notify_service_spec.rb
index 809b12910a1..4674f614cf1 100644
--- a/spec/services/projects/alerting/notify_service_spec.rb
+++ b/spec/services/projects/alerting/notify_service_spec.rb
@@ -34,13 +34,11 @@ RSpec.describe Projects::Alerting::NotifyService do
let(:payload) { ActionController::Parameters.new(payload_raw).permit! }
- subject { service.execute(token) }
-
- context 'with activated Alerts Service' do
- let_it_be_with_reload(:alerts_service) { create(:alerts_service, project: project) }
+ subject { service.execute(token, nil) }
+ shared_examples 'notifcations are handled correctly' do
context 'with valid token' do
- let(:token) { alerts_service.token }
+ let(:token) { integration.token }
let(:incident_management_setting) { double(send_email?: email_enabled, create_issue?: issue_enabled, auto_close_incident?: auto_close_enabled) }
let(:email_enabled) { false }
let(:issue_enabled) { false }
@@ -131,6 +129,12 @@ RSpec.describe Projects::Alerting::NotifyService do
it { expect { subject }.to change { issue.reload.state }.from('opened').to('closed') }
it { expect { subject }.to change(ResourceStateEvent, :count).by(1) }
end
+
+ context 'with issue enabled' do
+ let(:issue_enabled) { true }
+
+ it_behaves_like 'does not process incident issues'
+ end
end
end
@@ -197,7 +201,7 @@ RSpec.describe Projects::Alerting::NotifyService do
it 'creates a system note corresponding to alert creation' do
expect { subject }.to change(Note, :count).by(1)
- expect(Note.last.note).to include('Generic Alert Endpoint')
+ expect(Note.last.note).to include(source)
end
end
end
@@ -247,10 +251,20 @@ RSpec.describe Projects::Alerting::NotifyService do
it_behaves_like 'does not process incident issues due to error', http_status: :unauthorized
it_behaves_like 'does not an create alert management alert'
end
+ end
+
+ context 'with an HTTP Integration' do
+ let_it_be_with_reload(:integration) { create(:alert_management_http_integration, project: project) }
+
+ subject { service.execute(token, integration) }
+
+ it_behaves_like 'notifcations are handled correctly' do
+ let(:source) { integration.name }
+ end
- context 'with deactivated Alerts Service' do
+ context 'with deactivated HTTP Integration' do
before do
- alerts_service.update!(active: false)
+ integration.update!(active: false)
end
it_behaves_like 'does not process incident issues due to error', http_status: :forbidden