Fix a potential frozen string error in app/mailers/notify.rb
Signed-off-by: Rémy Coutable <remy@rymai.me>
This commit is contained in:
parent
b388111f6e
commit
24f9fa11a3
4 changed files with 17 additions and 11 deletions
|
@ -128,7 +128,7 @@ class Notify < BaseMailer
|
|||
address.display_name = reply_display_name(model)
|
||||
end
|
||||
|
||||
fallback_reply_message_id = "<reply-#{reply_key}@#{Gitlab.config.gitlab.host}>".freeze
|
||||
fallback_reply_message_id = "<reply-#{reply_key}@#{Gitlab.config.gitlab.host}>"
|
||||
headers['References'] ||= []
|
||||
headers['References'].unshift(fallback_reply_message_id)
|
||||
|
||||
|
@ -178,7 +178,7 @@ class Notify < BaseMailer
|
|||
|
||||
headers['X-GitLab-Discussion-ID'] = note.discussion.id if note.part_of_discussion?
|
||||
|
||||
headers[:subject]&.prepend('Re: ')
|
||||
headers[:subject] = "Re: #{headers[:subject]}" if headers[:subject]
|
||||
|
||||
mail_thread(model, headers)
|
||||
end
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Fix a potential frozen string error in app/mailers/notify.rb
|
||||
merge_request: 23728
|
||||
author:
|
||||
type: fixed
|
|
@ -4,6 +4,7 @@ require 'email_spec'
|
|||
describe Notify do
|
||||
include EmailSpec::Helpers
|
||||
include EmailSpec::Matchers
|
||||
include EmailHelpers
|
||||
include RepoHelpers
|
||||
|
||||
include_context 'gitlab email notification'
|
||||
|
@ -27,15 +28,6 @@ describe Notify do
|
|||
description: 'My awesome description!')
|
||||
end
|
||||
|
||||
def have_referable_subject(referable, reply: false)
|
||||
prefix = (referable.project ? "#{referable.project.name} | " : '').freeze
|
||||
prefix = "Re: #{prefix}" if reply
|
||||
|
||||
suffix = "#{referable.title} (#{referable.to_reference})"
|
||||
|
||||
have_subject [prefix, suffix].compact.join
|
||||
end
|
||||
|
||||
context 'for a project' do
|
||||
shared_examples 'an assignee email' do
|
||||
it 'is sent to the assignee as the author' do
|
||||
|
|
|
@ -34,4 +34,13 @@ module EmailHelpers
|
|||
def find_email_for(user)
|
||||
ActionMailer::Base.deliveries.find { |d| d.to.include?(user.notification_email) }
|
||||
end
|
||||
|
||||
def have_referable_subject(referable, include_project: true, reply: false)
|
||||
prefix = (include_project && referable.project ? "#{referable.project.name} | " : '').freeze
|
||||
prefix = "Re: #{prefix}" if reply
|
||||
|
||||
suffix = "#{referable.title} (#{referable.to_reference})"
|
||||
|
||||
have_subject [prefix, suffix].compact.join
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue