From 36b255e57bae0dbfbb0e1767713bdd713c48d622 Mon Sep 17 00:00:00 2001 From: Aleks Bunin Date: Sat, 7 Feb 2015 12:35:50 -0500 Subject: [PATCH] Addex X-GitLab-Project header to GitLab emails. Fixes #8748. --- app/mailers/notify.rb | 2 ++ spec/mailers/notify_spec.rb | 2 ++ 2 files changed, 4 insertions(+) diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb index 5ae07d771fa..3b7152cb771 100644 --- a/app/mailers/notify.rb +++ b/app/mailers/notify.rb @@ -111,6 +111,7 @@ class Notify < ActionMailer::Base # See: mail_answer_thread def mail_new_thread(model, headers = {}, &block) headers['Message-ID'] = message_id(model) + headers['X-GitLab-Project'] = "#{@project.name} | " if @project mail(headers, &block) end @@ -125,6 +126,7 @@ class Notify < ActionMailer::Base def mail_answer_thread(model, headers = {}, &block) headers['In-Reply-To'] = message_id(model) headers['References'] = message_id(model) + headers['X-GitLab-Project'] = "#{@project.name} | " if @project if (headers[:subject]) headers[:subject].prepend('Re: ') diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index a0c37587b23..a66c986148e 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -26,6 +26,7 @@ describe Notify do shared_examples 'an email starting a new thread' do |message_id_prefix| it 'has a discussion identifier' do should have_header 'Message-ID', /<#{message_id_prefix}(.*)@#{Gitlab.config.gitlab.host}>/ + should have_header 'X-GitLab-Project', /#{project.name}/ end end @@ -37,6 +38,7 @@ describe Notify do it 'has headers that reference an existing thread' do should have_header 'References', /<#{thread_id_prefix}(.*)@#{Gitlab.config.gitlab.host}>/ should have_header 'In-Reply-To', /<#{thread_id_prefix}(.*)@#{Gitlab.config.gitlab.host}>/ + should have_header 'X-GitLab-Project', /#{project.name}/ end end