Commit 5b6ad9d5 authored by David Kim's avatar David Kim

Merge branch 'ck3g-add-incident-type-to-alert-issue-factory' into 'master'

Create issue of type incident from alert factory

See merge request gitlab-org/gitlab!67126
parents d63213fb 3fb6f6af
......@@ -15,9 +15,9 @@ FactoryBot.define do
end
end
trait :with_issue do
trait :with_incident do
after(:create) do |alert|
create(:issue, alert_management_alert: alert, project: alert.project)
create(:incident, alert_management_alert: alert, project: alert.project)
end
end
......@@ -128,7 +128,7 @@ FactoryBot.define do
end
trait :all_fields do
with_issue
with_incident
with_assignee
with_fingerprint
with_service
......
......@@ -48,7 +48,7 @@ RSpec.describe Emails::Projects do
end
context 'with incident' do
let(:alert) { create(:alert_management_alert, :with_issue, :from_payload, payload: payload, project: project) }
let(:alert) { create(:alert_management_alert, :with_incident, :from_payload, payload: payload, project: project) }
let(:incident) { alert.issue }
it 'has expected X-GitLab incident headers', :aggregate_failures do
......
......@@ -40,7 +40,7 @@ RSpec.describe 'getting Alert Management Alert Issue' do
context 'with gitlab alert' do
before do
create(:alert_management_alert, :with_issue, project: project, payload: payload)
create(:alert_management_alert, :with_incident, project: project, payload: payload)
end
it 'includes the correct alert issue payload data' do
......@@ -57,7 +57,7 @@ RSpec.describe 'getting Alert Management Alert Issue' do
context 'with gitlab alert' do
before do
create(:alert_management_alert, :with_issue, project: project, payload: payload)
create(:alert_management_alert, :with_incident, project: project, payload: payload)
end
it 'avoids N+1 queries' do
......
......@@ -323,7 +323,7 @@ RSpec.describe 'getting an issue list for a project' do
it 'avoids N+1 queries' do
control = ActiveRecord::QueryRecorder.new { post_graphql(query, current_user: current_user) }
create(:alert_management_alert, :with_issue, project: project)
create(:alert_management_alert, :with_incident, project: project)
expect { post_graphql(query, current_user: current_user) }.not_to exceed_query_limit(control)
end
......
......@@ -745,7 +745,7 @@ RSpec.describe SystemNoteService do
end
describe '.new_alert_issue' do
let(:alert) { build(:alert_management_alert, :with_issue) }
let(:alert) { build(:alert_management_alert, :with_incident) }
it 'calls AlertManagementService' do
expect_next_instance_of(SystemNotes::AlertManagementService) do |service|
......
......@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe ::SystemNotes::AlertManagementService do
let_it_be(:author) { create(:user) }
let_it_be(:project) { create(:project, :repository) }
let_it_be(:noteable) { create(:alert_management_alert, :with_issue, :acknowledged, project: project) }
let_it_be(:noteable) { create(:alert_management_alert, :with_incident, :acknowledged, project: project) }
describe '#create_new_alert' do
subject { described_class.new(noteable: noteable, project: project).create_new_alert('Some Service') }
......
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