Commit 3e2875c3 authored by rpereira2's avatar rpereira2

Refactor notify_service specs

- Use it_behaves_like instead of include_examples.
- Remove some extra whitespace.
parent bbad4505
......@@ -183,11 +183,7 @@ describe Projects::Prometheus::Alerts::NotifyService do
context 'no incident_management license' do
before do
create(:prometheus_service, project: project)
create(:project_alerting_setting,
project: project,
token: token)
create(:project_alerting_setting, project: project, token: token)
create(:project_incident_management_setting, send_email: false, project: project)
allow(project).to receive(:feature_available?).and_call_original
......@@ -195,16 +191,13 @@ describe Projects::Prometheus::Alerts::NotifyService do
.with(:incident_management).and_return(false)
end
include_examples 'notifies alerts'
it_behaves_like 'notifies alerts'
end
context 'with incident_management license' do
before do
create(:prometheus_service, project: project)
create(:project_alerting_setting,
project: project,
token: token)
create(:project_alerting_setting, project: project, token: token)
allow(project).to receive(:feature_available?).and_call_original
allow(project).to receive(:feature_available?)
......@@ -212,7 +205,7 @@ describe Projects::Prometheus::Alerts::NotifyService do
end
context 'when incident_management_setting does not exist' do
include_examples 'notifies alerts'
it_behaves_like 'notifies alerts'
end
context 'when incident_management_setting.send_email is true' do
......@@ -220,11 +213,11 @@ describe Projects::Prometheus::Alerts::NotifyService do
create(:project_incident_management_setting, send_email: true, project: project)
end
include_examples 'notifies alerts'
it_behaves_like 'notifies alerts'
end
context 'incident_management_setting.send_email is false' do
before do
let(:incident_mgmt_settings) do
create(:project_incident_management_setting, send_email: false, project: project)
end
......@@ -232,7 +225,8 @@ describe Projects::Prometheus::Alerts::NotifyService do
it 'does not send notification' do
expect(project.feature_available?(:incident_management)).to eq(true)
expect(project).to receive(:incident_management_setting).and_call_original
expect(project).to receive(:incident_management_setting).and_return(incident_mgmt_settings)
expect(incident_mgmt_settings).to receive(:send_email)
expect(NotificationService).not_to receive(:new)
expect(subject).to eq(true)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment