Commit 909308c1 authored by James Lopez's avatar James Lopez

Merge branch '217920-add-alert_management_alert-invalid-trait' into 'master'

Add :with_validation_errors trait for Alert factory

Closes #217920

See merge request gitlab-org/gitlab!32650
parents 0e30d1fc 00f87838
......@@ -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