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

notifications_shared_examples.rb « alert_processing « alert_management « services « shared_examples « support « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 92e7dee7533d9ceed6734b9640ea19f2423cf121 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# frozen_string_literal: true

# Expects usage of 'incident management settings enabled' context.
#
# This shared_example includes the following option:
# - count: number of notifications expected to be sent
RSpec.shared_examples 'sends alert notification emails if enabled' do |count: 1|
  include_examples 'sends alert notification emails', count: count

  context 'with email setting disabled' do
    let(:send_email) { false }

    it_behaves_like 'does not send alert notification emails'
  end
end

RSpec.shared_examples 'sends alert notification emails' do |count: 1|
  let(:notification_async) { double(NotificationService::Async) }

  specify do
    allow(NotificationService).to receive_message_chain(:new, :async).and_return(notification_async)
    expect(notification_async).to receive(:prometheus_alerts_fired).exactly(count).times

    subject
  end
end

RSpec.shared_examples 'does not send alert notification emails' do
  specify do
    expect(NotificationService).not_to receive(:new)

    subject
  end
end