Commit 958588b8 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'pl-incident-issue-hline' into 'master'

Fix markdown layout of incident issues

See merge request gitlab-org/gitlab!25352
parents 5aca1bd5 ebdabb5f
...@@ -58,7 +58,7 @@ module IncidentManagement ...@@ -58,7 +58,7 @@ module IncidentManagement
end end
def issue_description def issue_description
horizontal_line = "\n---\n\n" horizontal_line = "\n\n---\n\n"
[ [
alert_summary, alert_summary,
......
---
title: Fix markdown layout of incident issues
merge_request: 25352
author:
type: fixed
...@@ -4,7 +4,7 @@ require 'spec_helper' ...@@ -4,7 +4,7 @@ require 'spec_helper'
describe IncidentManagement::CreateIssueService do describe IncidentManagement::CreateIssueService do
let(:project) { create(:project, :repository, :private) } let(:project) { create(:project, :repository, :private) }
let(:user) { User.alert_bot } let_it_be(:user) { User.alert_bot }
let(:service) { described_class.new(project, alert_payload) } let(:service) { described_class.new(project, alert_payload) }
let(:alert_starts_at) { Time.now } let(:alert_starts_at) { Time.now }
let(:alert_title) { 'TITLE' } let(:alert_title) { 'TITLE' }
...@@ -29,7 +29,6 @@ describe IncidentManagement::CreateIssueService do ...@@ -29,7 +29,6 @@ describe IncidentManagement::CreateIssueService do
context 'when create_issue enabled' do context 'when create_issue enabled' do
let(:issue) { subject[:issue] } let(:issue) { subject[:issue] }
let(:summary_separator) { "\n---\n\n" }
before do before do
setting.update!(create_issue: true) setting.update!(create_issue: true)
...@@ -42,7 +41,7 @@ describe IncidentManagement::CreateIssueService do ...@@ -42,7 +41,7 @@ describe IncidentManagement::CreateIssueService do
expect(issue.author).to eq(user) expect(issue.author).to eq(user)
expect(issue.title).to eq(alert_title) expect(issue.title).to eq(alert_title)
expect(issue.description).to include(alert_presenter.issue_summary_markdown.strip) expect(issue.description).to include(alert_presenter.issue_summary_markdown.strip)
expect(separator_count(issue.description)).to eq 0 expect(separator_count(issue.description)).to eq(0)
end end
end end
...@@ -74,7 +73,7 @@ describe IncidentManagement::CreateIssueService do ...@@ -74,7 +73,7 @@ describe IncidentManagement::CreateIssueService do
expect(subject).to include(status: :success) expect(subject).to include(status: :success)
expect(issue.description).to include(alert_presenter.issue_summary_markdown) expect(issue.description).to include(alert_presenter.issue_summary_markdown)
expect(separator_count(issue.description)).to eq 1 expect(separator_count(issue.description)).to eq(1)
expect(issue.description).to include(template_content) expect(issue.description).to include(template_content)
end end
end end
...@@ -134,7 +133,7 @@ describe IncidentManagement::CreateIssueService do ...@@ -134,7 +133,7 @@ describe IncidentManagement::CreateIssueService do
expect(issue.description).to include(alert_presenter.issue_summary_markdown) expect(issue.description).to include(alert_presenter.issue_summary_markdown)
expect(issue.description).to include(template_content) expect(issue.description).to include(template_content)
expect(issue.description).to include(alt_template) expect(issue.description).to include(alt_template)
expect(separator_count(issue.description)).to eq 2 expect(separator_count(issue.description)).to eq(2)
end end
end end
...@@ -171,7 +170,7 @@ describe IncidentManagement::CreateIssueService do ...@@ -171,7 +170,7 @@ describe IncidentManagement::CreateIssueService do
expect(issue.title).to include(query_title) expect(issue.title).to include(query_title)
expect(issue.title).to include('for 5 minutes') expect(issue.title).to include('for 5 minutes')
expect(issue.description).to include(alert_presenter.issue_summary_markdown.strip) expect(issue.description).to include(alert_presenter.issue_summary_markdown.strip)
expect(separator_count(issue.description)).to eq 0 expect(separator_count(issue.description)).to eq(0)
end end
end end
...@@ -306,6 +305,8 @@ describe IncidentManagement::CreateIssueService do ...@@ -306,6 +305,8 @@ describe IncidentManagement::CreateIssueService do
end end
def separator_count(text) def separator_count(text)
summary_separator = "\n\n---\n\n"
text.scan(summary_separator).size text.scan(summary_separator).size
end end
end end
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