Commit 084cd09f authored by Sean Arnold's avatar Sean Arnold

Update sla label specs

- add changelog
parent f983eb8c
---
title: Add Missed SLA label via Cron job
merge_request: 44546
author:
type: added
...@@ -11,10 +11,7 @@ module IncidentManagement ...@@ -11,10 +11,7 @@ module IncidentManagement
def perform def perform
IssuableSla.exceeded_for_issues.find_in_batches do |incident_slas| IssuableSla.exceeded_for_issues.find_in_batches do |incident_slas|
incident_slas.each do |incident_sla| incident_slas.each do |incident_sla|
ApplyIncidentSlaExceededLabelWorker.perform_async(incident_sla.issue.id) ApplyIncidentSlaExceededLabelWorker.perform_async(incident_sla.issue_id)
rescue StandardError => e
Gitlab::AppLogger.error("Error encountered in #{self.class.name}: #{e}")
end end
end end
end end
......
...@@ -29,9 +29,9 @@ RSpec.describe IncidentManagement::ApplyIncidentSlaExceededLabelWorker do ...@@ -29,9 +29,9 @@ RSpec.describe IncidentManagement::ApplyIncidentSlaExceededLabelWorker do
it 'adds a label to the incident' do it 'adds a label to the incident' do
expect { perform }.to change { incident.labels.reload.count }.by(1) expect { perform }.to change { incident.labels.reload.count }.by(1)
expected_props = IncidentManagement::CreateIncidentSlaExceededLabelService::LABEL_PROPERTIES expected_label = project.labels.find_by!(IncidentManagement::CreateIncidentSlaExceededLabelService::LABEL_PROPERTIES)
expect(perform).to have_attributes(expected_props) expect(perform).to eq(expected_label)
end end
it 'adds a note that the label was added' do it 'adds a note that the label was added' do
......
...@@ -21,25 +21,5 @@ RSpec.describe IncidentManagement::IncidentSlaExceededCheckWorker do ...@@ -21,25 +21,5 @@ RSpec.describe IncidentManagement::IncidentSlaExceededCheckWorker do
perform perform
end end
context 'when error occurs' do
before do
allow(IncidentManagement::ApplyIncidentSlaExceededLabelWorker)
.to receive(:perform_async)
.twice
allow(IncidentManagement::ApplyIncidentSlaExceededLabelWorker)
.to receive(:perform_async)
.with(incident_sla.issue.id)
.and_raise('test')
.once
end
it 'logs the error and continues to run the others' do
expect(Gitlab::AppLogger).to receive(:error).once
perform
end
end
end end
end end
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