Commit 00f87838 authored by Vitali Tatarintev's avatar Vitali Tatarintev

Add :with_validation_errors trait for Alert

parent 339c39b3
......@@ -8,6 +8,13 @@ FactoryBot.define do
title { FFaker::Lorem.sentence }
started_at { Time.current }
trait :with_validation_errors do
after(:create) do |alert|
too_many_hosts = Array.new(AlertManagement::Alert::HOSTS_MAX_LENGTH + 1) { |_| 'host' }
alert.update_columns(hosts: too_many_hosts)
end
end
trait :with_issue do
issue
end
......
......@@ -94,11 +94,7 @@ RSpec.describe AlertManagement::CreateAlertIssueService do
end
context 'when alert cannot be updated' do
before do
# invalidate alert
too_many_hosts = Array.new(AlertManagement::Alert::HOSTS_MAX_LENGTH + 1) { |_| 'host' }
alert.update_columns(hosts: too_many_hosts)
end
let(:alert) { create(:alert_management_alert, :with_validation_errors, :triggered, project: project, payload: payload) }
it 'responds with error' do
expect(execute).to be_error
......
......@@ -70,11 +70,7 @@ describe IncidentManagement::ProcessAlertWorker do
end
context 'when alert cannot be updated' do
before do
# invalidate alert
too_many_hosts = Array.new(AlertManagement::Alert::HOSTS_MAX_LENGTH + 1) { |_| 'host' }
alert.update_columns(hosts: too_many_hosts)
end
let(:alert) { create(:alert_management_alert, :with_validation_errors, project: project) }
it 'updates AlertManagement::Alert#issue_id' do
expect { subject }.not_to change { alert.reload.issue_id }
......
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