diff options
author | Rémy Coutable <remy@rymai.me> | 2018-12-11 15:33:27 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-12-11 17:13:42 +0300 |
commit | 24f9fa11a317f04e75b63e241d0ceeb75fdd38a8 (patch) | |
tree | 4b411cd9fc03c7315e4aaaea4a2babde578f1a26 | |
parent | b388111f6ed5181c357f5c37277f16c6ae234f5a (diff) |
Fix a potential frozen string error in app/mailers/notify.rb
Signed-off-by: Rémy Coutable <remy@rymai.me>
-rw-r--r-- | app/mailers/notify.rb | 4 | ||||
-rw-r--r-- | changelogs/unreleased/55183-frozenerror-can-t-modify-frozen-string-in-app-mailers-notify-rb.yml | 5 | ||||
-rw-r--r-- | spec/mailers/notify_spec.rb | 10 | ||||
-rw-r--r-- | spec/support/helpers/email_helpers.rb | 9 |
4 files changed, 17 insertions, 11 deletions
diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb index 88ad4c3e893..6d86b60c50c 100644 --- a/app/mailers/notify.rb +++ b/app/mailers/notify.rb @@ -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 diff --git a/changelogs/unreleased/55183-frozenerror-can-t-modify-frozen-string-in-app-mailers-notify-rb.yml b/changelogs/unreleased/55183-frozenerror-can-t-modify-frozen-string-in-app-mailers-notify-rb.yml new file mode 100644 index 00000000000..685a8309c72 --- /dev/null +++ b/changelogs/unreleased/55183-frozenerror-can-t-modify-frozen-string-in-app-mailers-notify-rb.yml @@ -0,0 +1,5 @@ +--- +title: Fix a potential frozen string error in app/mailers/notify.rb +merge_request: 23728 +author: +type: fixed diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index 1d17aec0ded..f6e5c9d33ac 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -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 diff --git a/spec/support/helpers/email_helpers.rb b/spec/support/helpers/email_helpers.rb index 1fb8252459f..ad6e1064499 100644 --- a/spec/support/helpers/email_helpers.rb +++ b/spec/support/helpers/email_helpers.rb @@ -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 |