Commit 47a5633e authored by Peter Leitzen's avatar Peter Leitzen Committed by Sean McGivern

Resolve "Open issues from alerts as `GitLab Alert Bot`"

parent 1838cc1d
......@@ -74,7 +74,8 @@ module EE
scope :group_view_details, -> { where('group_view = ? OR group_view IS NULL', group_view[:details]) }
enum bot_type: {
support_bot: 1
support_bot: 1,
alert_bot: 2
}
end
......@@ -90,6 +91,15 @@ module EE
end
end
def alert_bot
email_pattern = "alert%s@#{Settings.gitlab.host}"
unique_internal(where(bot_type: :alert_bot), 'alert-bot', email_pattern) do |u|
u.bio = 'The GitLab alert bot'
u.name = 'GitLab Alert Bot'
end
end
override :internal
def internal
super.or(where.not(bot_type: nil))
......
......@@ -24,9 +24,7 @@ module IncidentManagement
def issue_author
strong_memoize(:issue_author) do
# This is a temporary solution before we've implemented User.alert_bot
# https://gitlab.com/gitlab-org/gitlab-ee/issues/10159
User.ghost
User.alert_bot
end
end
......
---
title: Let the GitLab Alert bot open incident issues
merge_request: 10460
author:
type: added
......@@ -524,8 +524,9 @@ describe User do
let!(:user) { create(:user) }
let!(:ghost) { described_class.ghost }
let!(:support_bot) { described_class.support_bot }
let!(:alert_bot) { described_class.alert_bot }
let!(:non_internal) { [user] }
let!(:internal) { [ghost, support_bot] }
let!(:internal) { [ghost, support_bot, alert_bot] }
it 'returns non internal users' do
expect(described_class.internal).to eq(internal)
......@@ -543,6 +544,7 @@ describe User do
expect(ghost.bot?).to eq(false)
expect(support_bot.bot?).to eq(true)
expect(alert_bot.bot?).to eq(true)
end
end
end
......
......@@ -28,7 +28,7 @@ describe IncidentManagement::CreateIssueService do
expect(subject).to include(status: :success)
issue = subject[:issue]
expect(issue.author).to eq(User.ghost)
expect(issue.author).to eq(User.alert_bot)
expect(issue.title).to eq(alert_title)
expect(issue.description).to include('Summary')
expect(issue.description).to include(alert_title)
......
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