Commit fb00525a authored by Stan Hu's avatar Stan Hu

Merge branch '55183-frozenerror-can-t-modify-frozen-string-in-app-mailers-notify-rb' into 'master'

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

Closes #55183

See merge request gitlab-org/gitlab-ce!23728
parents fd703ce0 24f9fa11
......@@ -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
......
---
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
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