Commit c077a9bd authored by Rémy Coutable's avatar Rémy Coutable

Fix a potential frozen string error in app/mailers/notify.rb

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 59e20557
...@@ -130,7 +130,7 @@ class Notify < BaseMailer ...@@ -130,7 +130,7 @@ class Notify < BaseMailer
address.display_name = reply_display_name(model) address.display_name = reply_display_name(model)
end 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'] ||= []
headers['References'].unshift(fallback_reply_message_id) headers['References'].unshift(fallback_reply_message_id)
...@@ -180,7 +180,7 @@ class Notify < BaseMailer ...@@ -180,7 +180,7 @@ class Notify < BaseMailer
headers['X-GitLab-Discussion-ID'] = note.discussion.id if note.part_of_discussion? 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) mail_thread(model, headers)
end end
......
---
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' ...@@ -4,6 +4,7 @@ require 'email_spec'
describe Notify do describe Notify do
include EmailSpec::Helpers include EmailSpec::Helpers
include EmailSpec::Matchers include EmailSpec::Matchers
include EmailHelpers
include RepoHelpers include RepoHelpers
include_context 'gitlab email notification' include_context 'gitlab email notification'
...@@ -27,15 +28,6 @@ describe Notify do ...@@ -27,15 +28,6 @@ describe Notify do
description: 'My awesome description!') description: 'My awesome description!')
end 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 context 'for a project' do
shared_examples 'an assignee email' do shared_examples 'an assignee email' do
it 'is sent to the assignee as the author' do it 'is sent to the assignee as the author' do
......
...@@ -34,4 +34,13 @@ module EmailHelpers ...@@ -34,4 +34,13 @@ module EmailHelpers
def find_email_for(user) def find_email_for(user)
ActionMailer::Base.deliveries.find { |d| d.to.include?(user.notification_email) } ActionMailer::Base.deliveries.find { |d| d.to.include?(user.notification_email) }
end 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 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