diff --git a/app/mailers/emails/merge_requests.rb b/app/mailers/emails/merge_requests.rb index 935987e2ed166b5a972c6f0e97a4f6827d06c1fe..9ecdac87d722cddd3c271be681f0e9f1fb673a6a 100644 --- a/app/mailers/emails/merge_requests.rb +++ b/app/mailers/emails/merge_requests.rb @@ -49,9 +49,10 @@ module Emails @updated_by = User.find updated_by_user_id @target_url = project_merge_request_url(@project, @merge_request) set_reference("merge_request_#{merge_request_id}") - mail(from: sender(updated_by_user_id), - to: recipient(recipient_id), - subject: subject("#{@merge_request.title} (##{@merge_request.iid}) #{@mr_status}")) + mail_answer_thread(@merge_request, + from: sender(updated_by_user_id), + to: recipient(recipient_id), + subject: subject("#{@merge_request.title} (##{@merge_request.iid}) #{@mr_status}")) end end diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index 314b2691c40d31e721cdc62d4d2391e49f8f6025..25872b3a257dea61cd40393abc1ab925215218ed 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -322,6 +322,35 @@ describe Notify do end end + describe 'status changed' do + let(:status) { 'reopened' } + subject { Notify.merge_request_status_email(recipient.id, merge_request.id, status, current_user) } + + it_behaves_like 'an answer to an existing thread', 'merge_request' + + it 'is sent as the author' do + sender = subject.header[:from].addrs[0] + sender.display_name.should eq(current_user.name) + sender.address.should eq(gitlab_sender) + end + + it 'has the correct subject' do + should have_subject /#{merge_request.title} \(##{merge_request.iid}\)/i + end + + it 'contains the new status' do + should have_body_text /#{status}/i + end + + it 'contains the user name' do + should have_body_text /#{current_user.name}/i + end + + it 'contains a link to the merge request' do + should have_body_text /#{project_merge_request_path project, merge_request}/ + end + end + describe 'that are merged' do subject { Notify.merged_merge_request_email(recipient.id, merge_request.id, merge_author.id) }