diff --git a/app/mailers/emails/merge_requests.rb b/app/mailers/emails/merge_requests.rb index be99f3780cc..b3f2aeb08ca 100644 --- a/app/mailers/emails/merge_requests.rb +++ b/app/mailers/emails/merge_requests.rb @@ -15,6 +15,7 @@ module Emails setup_merge_request_mail(merge_request_id, recipient_id) @new_commits = new_commits @existing_commits = existing_commits + @updated_by_user = User.find(updated_by_user_id) mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, recipient_id, reason)) end diff --git a/app/views/notify/push_to_merge_request_email.html.haml b/app/views/notify/push_to_merge_request_email.html.haml index 5cc6f21c0f3..4c507c08ed7 100644 --- a/app/views/notify/push_to_merge_request_email.html.haml +++ b/app/views/notify/push_to_merge_request_email.html.haml @@ -1,7 +1,7 @@ %h3 - New commits were pushed to the merge request + = @updated_by_user.name + pushed new commits to merge request = link_to(@merge_request.to_reference, project_merge_request_url(@merge_request.target_project, @merge_request)) - by #{@current_user.name} - if @existing_commits.any? - count = @existing_commits.size diff --git a/app/views/notify/push_to_merge_request_email.text.haml b/app/views/notify/push_to_merge_request_email.text.haml index d7722e5f41f..553f771f1a6 100644 --- a/app/views/notify/push_to_merge_request_email.text.haml +++ b/app/views/notify/push_to_merge_request_email.text.haml @@ -1,4 +1,4 @@ -New commits were pushed to the merge request #{@merge_request.to_reference} by #{@current_user.name} +#{@updated_by_user.name} pushed new commits to merge request #{@merge_request.to_reference} \ #{url_for(project_merge_request_url(@merge_request.target_project, @merge_request))} \ diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index 83c33797bbc..971a88e9ee9 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -389,6 +389,36 @@ describe Notify do end end end + + describe 'that have new commits' do + let(:push_user) { create(:user) } + + subject do + described_class.push_to_merge_request_email(recipient.id, merge_request.id, push_user.id, new_commits: merge_request.commits) + end + + it_behaves_like 'a multiple recipients email' + it_behaves_like 'an answer to an existing thread with reply-by-email enabled' do + let(:model) { merge_request } + end + it_behaves_like 'it should show Gmail Actions View Merge request link' + it_behaves_like 'an unsubscribeable thread' + + it 'is sent as the push user' do + sender = subject.header[:from].addrs[0] + + expect(sender.display_name).to eq(push_user.name) + expect(sender.address).to eq(gitlab_sender) + end + + it 'has the correct subject and body' do + aggregate_failures do + is_expected.to have_referable_subject(merge_request, reply: true) + is_expected.to have_body_text("#{push_user.name} pushed new commits") + is_expected.to have_body_text(project_merge_request_path(project, merge_request)) + end + end + end end context 'for issue notes' do