Commit 1d7ab298 authored by Dylan Griffith's avatar Dylan Griffith

Merge branch 'add_missing_email_subject_suffix' into 'master'

Add missing suffixes to notification mails

See merge request gitlab-org/gitlab!64767
parents 6b7ded28 6f61e6d6
......@@ -32,7 +32,7 @@ module Emails
# thousand times. This could be potentially expensive in a loop, and
# recipients would contain all project watchers so it could be a lot.
mail(bcc: recipients,
subject: pipeline_subject(status)) do |format|
subject: subject(pipeline_subject(status))) do |format|
format.html { render layout: 'mailer' }
format.text { render layout: 'mailer' }
end
......@@ -53,7 +53,6 @@ module Emails
subject = []
subject << "#{status} pipeline for #{@pipeline.source_ref}"
subject << @project.name if @project
subject << @pipeline.short_sha
subject.join(' | ')
......
......@@ -9,12 +9,14 @@ RSpec.describe Emails::Pipelines do
let_it_be(:project) { create(:project, :repository) }
shared_examples_for 'correct pipeline information' do
it 'has a correct information' do
expect(subject)
.to have_subject "#{status} pipeline for #{pipeline.source_ref} | " \
"#{project.name} | " \
"#{pipeline.short_sha}".to_s
let(:expected_email_subject) do
"#{project.name} | " \
"#{status} pipeline for #{pipeline.source_ref} | " \
"#{pipeline.short_sha}"
end
it 'has a correct information' do
expect(subject).to have_subject expected_email_subject
expect(subject).to have_body_text pipeline.source_ref
expect(subject).to have_body_text status_text
end
......@@ -28,11 +30,7 @@ RSpec.describe Emails::Pipelines do
end
it 'has correct information that there is no merge request link' do
expect(subject)
.to have_subject "#{status} pipeline for #{pipeline.source_ref} | " \
"#{project.name} | " \
"#{pipeline.short_sha}".to_s
expect(subject).to have_subject expected_email_subject
expect(subject).to have_body_text pipeline.source_ref
expect(subject).to have_body_text status_text
end
......@@ -48,11 +46,7 @@ RSpec.describe Emails::Pipelines do
end
it 'has correct information that there is a merge request link' do
expect(subject)
.to have_subject "#{status} pipeline for #{pipeline.source_ref} | " \
"#{project.name} | " \
"#{pipeline.short_sha}".to_s
expect(subject).to have_subject expected_email_subject
expect(subject).to have_body_text merge_request.to_reference
expect(subject).to have_body_text pipeline.source_ref
expect(subject).not_to have_body_text pipeline.ref
......@@ -70,11 +64,7 @@ RSpec.describe Emails::Pipelines do
end
it 'has correct information that there is a merge request link' do
expect(subject)
.to have_subject "#{status} pipeline for #{pipeline.source_ref} | " \
"#{project.name} | " \
"#{pipeline.short_sha}".to_s
expect(subject).to have_subject expected_email_subject
expect(subject).to have_body_text merge_request.to_reference
expect(subject).to have_body_text pipeline.source_ref
end
......@@ -91,6 +81,17 @@ RSpec.describe Emails::Pipelines do
it_behaves_like 'correct pipeline information' do
let(:status) { 'Successful' }
let(:status_text) { "Pipeline ##{pipeline.id} has passed!" }
let(:email_subject_suffix) { 'A Nice Suffix' }
let(:expected_email_subject) do
"#{project.name} | " \
"#{status} pipeline for #{pipeline.source_ref} | " \
"#{pipeline.short_sha} | " \
"#{email_subject_suffix}"
end
before do
stub_config_setting(email_subject_suffix: email_subject_suffix)
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