Commit cc7a585e authored by syasonik's avatar syasonik

Unify approach of separator assertions

parent fc55e30d
...@@ -28,7 +28,7 @@ describe IncidentManagement::CreateIssueService do ...@@ -28,7 +28,7 @@ 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" } let(:summary_separator) { "\n---\n\n" }
before do before do
setting.update!(create_issue: true) setting.update!(create_issue: true)
...@@ -41,7 +41,7 @@ describe IncidentManagement::CreateIssueService do ...@@ -41,7 +41,7 @@ describe IncidentManagement::CreateIssueService do
expect(issue.author).to eq(User.alert_bot) expect(issue.author).to eq(User.alert_bot)
expect(issue.title).to eq(alert_title) expect(issue.title).to eq(alert_title)
expect(issue.description).to include(alert_presenter.issue_summary_markdown) expect(issue.description).to include(alert_presenter.issue_summary_markdown)
expect(issue.description).not_to include(summary_separator) expect(separator_count(issue.description)).to eq 0
end end
end end
...@@ -53,7 +53,7 @@ describe IncidentManagement::CreateIssueService do ...@@ -53,7 +53,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(issue.description).to include(summary_separator) 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
...@@ -113,7 +113,7 @@ describe IncidentManagement::CreateIssueService do ...@@ -113,7 +113,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(issue.description.scan(summary_separator).size).to eq(2) expect(separator_count(issue.description)).to eq 2
end end
end end
...@@ -150,7 +150,7 @@ describe IncidentManagement::CreateIssueService do ...@@ -150,7 +150,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) expect(issue.description).to include(alert_presenter.issue_summary_markdown)
expect(issue.description).not_to include(summary_separator) expect(separator_count(issue.description)).to eq 0
end end
end end
...@@ -206,4 +206,8 @@ describe IncidentManagement::CreateIssueService do ...@@ -206,4 +206,8 @@ describe IncidentManagement::CreateIssueService do
def error_message(message) def error_message(message)
%{Cannot create incident issue for "#{project.full_name}": #{message}} %{Cannot create incident issue for "#{project.full_name}": #{message}}
end end
def separator_count(text)
text.scan(summary_separator).size
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