Commit d5f16102 authored by Andreas Brandl's avatar Andreas Brandl

Merge branch '11586-make-create-an-issue-default-for-incident-management' into 'master'

Resolve "Make "Create an issue" default for Incident Management"

Closes #11586

See merge request gitlab-org/gitlab-ee!12653
parents 13886c07 0bfaa68e
...@@ -2504,8 +2504,8 @@ ActiveRecord::Schema.define(version: 20190620112608) do ...@@ -2504,8 +2504,8 @@ ActiveRecord::Schema.define(version: 20190620112608) do
end end
create_table "project_incident_management_settings", primary_key: "project_id", id: :serial, force: :cascade do |t| create_table "project_incident_management_settings", primary_key: "project_id", id: :serial, force: :cascade do |t|
t.boolean "create_issue", default: false, null: false t.boolean "create_issue", default: true, null: false
t.boolean "send_email", default: true, null: false t.boolean "send_email", default: false, null: false
t.text "issue_template_key" t.text "issue_template_key"
end end
......
...@@ -31,6 +31,11 @@ module Projects ...@@ -31,6 +31,11 @@ module Projects
end end
def send_email? def send_email?
# Send email if the `incident_management` feature flag is disabled.
# This is done in order to keep the old behavior of sending emails for
# any project which does not have the new `incident_management` feature.
# See point 3 in
# https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/9830#what-does-this-mr-do
return firings.any? unless incident_management_available? return firings.any? unless incident_management_available?
incident_management_setting.send_email && firings.any? incident_management_setting.send_email && firings.any?
......
...@@ -28,5 +28,5 @@ ...@@ -28,5 +28,5 @@
= icon('chevron-down') = icon('chevron-down')
.form-group .form-group
= form.check_box :send_email = form.check_box :send_email
= form.label :send_email, _('Send an email notification to Developers.'), class: 'form-check-label' = form.label :send_email, _('Send a separate email notification to Developers.'), class: 'form-check-label'
= f.submit _('Save changes'), class: 'btn btn-success' = f.submit _('Save changes'), class: 'btn btn-success'
---
title: Create incident issues by default for alerts
merge_request: 12814
author:
type: changed
...@@ -7,7 +7,7 @@ describe 'Projects > Settings' do ...@@ -7,7 +7,7 @@ describe 'Projects > Settings' do
let(:project) { create(:project, :repository, create_templates: :issue) } let(:project) { create(:project, :repository, create_templates: :issue) }
let(:role) { :maintainer } let(:role) { :maintainer }
let(:create_issue) { 'Create an issue. Issues are created for each alert triggered.' } let(:create_issue) { 'Create an issue. Issues are created for each alert triggered.' }
let(:send_email) { 'Send an email notification to Developers.' } let(:send_email) { 'Send a separate email notification to Developers.' }
before do before do
create(:project_incident_management_setting, send_email: true, project: project) create(:project_incident_management_setting, send_email: true, project: project)
......
...@@ -26,8 +26,8 @@ describe ProjectsHelper do ...@@ -26,8 +26,8 @@ describe ProjectsHelper do
it 'builds incident_management_setting' do it 'builds incident_management_setting' do
expect(helper.project_incident_management_setting.persisted?).to be(false) expect(helper.project_incident_management_setting.persisted?).to be(false)
expect(helper.project_incident_management_setting.send_email).to be(true) expect(helper.project_incident_management_setting.send_email).to be(false)
expect(helper.project_incident_management_setting.create_issue).to be(false) expect(helper.project_incident_management_setting.create_issue).to be(true)
expect(helper.project_incident_management_setting.issue_template_key).to be(nil) expect(helper.project_incident_management_setting.issue_template_key).to be(nil)
end end
end end
......
...@@ -230,7 +230,17 @@ describe Projects::Prometheus::Alerts::NotifyService do ...@@ -230,7 +230,17 @@ describe Projects::Prometheus::Alerts::NotifyService do
end end
context 'when incident_management_setting does not exist' do context 'when incident_management_setting does not exist' do
it_behaves_like 'notifies alerts' it_behaves_like 'persists events'
it 'does not send notification email' do
expect(project.feature_available?(:incident_management)).to eq(true)
expect_next_instance_of(NotificationService) do |service|
expect(service).not_to receive(:async)
end
expect(subject).to eq(true)
end
end end
context 'when incident_management_setting.send_email is true' do context 'when incident_management_setting.send_email is true' do
......
...@@ -11889,7 +11889,7 @@ msgstr "" ...@@ -11889,7 +11889,7 @@ msgstr ""
msgid "Selecting a GitLab user will add a link to the GitLab user in the descriptions of issues and comments (e.g. \"By <a href=\"#\">@johnsmith</a>\"). It will also associate and/or assign these issues and comments with the selected user." msgid "Selecting a GitLab user will add a link to the GitLab user in the descriptions of issues and comments (e.g. \"By <a href=\"#\">@johnsmith</a>\"). It will also associate and/or assign these issues and comments with the selected user."
msgstr "" msgstr ""
msgid "Send an email notification to Developers." msgid "Send a separate email notification to Developers."
msgstr "" msgstr ""
msgid "Send confirmation email" msgid "Send confirmation email"
......
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