Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-16 00:08:49 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-16 00:08:49 +0300
commitcf1d4237a4f226ba2deed26240544da0675a41e5 (patch)
tree926a71b9279659bc52db0187b463603934718bf2 /spec/services
parent0ac82f99553ce12009970a14c0afc02d1f6515bb (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/projects/alerting/notify_service_spec.rb52
1 files changed, 51 insertions, 1 deletions
diff --git a/spec/services/projects/alerting/notify_service_spec.rb b/spec/services/projects/alerting/notify_service_spec.rb
index efd168a0a8a..925d323584e 100644
--- a/spec/services/projects/alerting/notify_service_spec.rb
+++ b/spec/services/projects/alerting/notify_service_spec.rb
@@ -5,6 +5,26 @@ require 'spec_helper'
describe Projects::Alerting::NotifyService do
let_it_be(:project, reload: true) { create(:project) }
+ before do
+ # We use `let_it_be(:project)` so we make sure to clear caches
+ project.clear_memoization(:licensed_feature_available)
+ end
+
+ shared_examples 'processes incident issues' do |amount|
+ let(:create_incident_service) { spy }
+
+ it 'processes issues' do
+ expect(IncidentManagement::ProcessAlertWorker)
+ .to receive(:perform_async)
+ .with(project.id, kind_of(Hash))
+ .exactly(amount).times
+
+ Sidekiq::Testing.inline! do
+ expect(subject.status).to eq(:success)
+ end
+ end
+ end
+
shared_examples 'does not process incident issues' do |http_status:|
it 'does not process issues' do
expect(IncidentManagement::ProcessAlertWorker)
@@ -29,6 +49,36 @@ describe Projects::Alerting::NotifyService do
subject { service.execute(token) }
- it_behaves_like 'does not process incident issues', http_status: 403
+ context 'with activated Alerts Service' do
+ let!(:alerts_service) { create(:alerts_service, project: project) }
+
+ context 'with valid token' do
+ let(:token) { alerts_service.token }
+
+ context 'with a valid payload' do
+ it_behaves_like 'processes incident issues', 1
+ end
+
+ context 'with an invalid payload' do
+ before do
+ allow(Gitlab::Alerting::NotificationPayloadParser)
+ .to receive(:call)
+ .and_raise(Gitlab::Alerting::NotificationPayloadParser::BadPayloadError)
+ end
+
+ it_behaves_like 'does not process incident issues', http_status: 400
+ end
+ end
+
+ context 'with invalid token' do
+ it_behaves_like 'does not process incident issues', http_status: 401
+ end
+ end
+
+ context 'with deactivated Alerts Service' do
+ let!(:alerts_service) { create(:alerts_service, :inactive, project: project) }
+
+ it_behaves_like 'does not process incident issues', http_status: 403
+ end
end
end