Commit f345890c authored by David Kim's avatar David Kim Committed by Mayra Cabrera

Add reviewers detail to merge request unmergeable email

We currently have Assignee information only on text version so we'll
follow the same reasoning to be consistent.
parent 79e19c5e
......@@ -92,6 +92,10 @@ class NotifyPreview < ActionMailer::Preview
Notify.merge_request_status_email(user.id, merge_request.id, 'reopened', user.id).message
end
def merge_request_unmergeable_email
Notify.merge_request_unmergeable_email(user.id, merge_request.id, 'conflict').message
end
def merged_merge_request_email
Notify.merged_merge_request_email(user.id, merge_request.id, user.id).message
end
......
......@@ -6,3 +6,4 @@ Merge Request URL: #{project_merge_request_url(@merge_request.target_project, @m
Author: #{sanitize_name(@merge_request.author_name)}
= assignees_label(@merge_request)
= reviewers_label(@merge_request)
---
title: Add reviewers detail to merge request unmergeable email
merge_request: 55582
author:
type: added
......@@ -24,6 +24,37 @@ RSpec.describe Emails::MergeRequests do
let(:recipient) { assignee }
let(:current_user_sanitized) { 'www_example_com' }
describe '#merge_request_unmergeable_email' do
subject { Notify.merge_request_unmergeable_email(recipient.id, merge_request.id) }
it_behaves_like 'an answer to an existing thread with reply-by-email enabled' do
let(:model) { merge_request }
end
it_behaves_like 'a multiple recipients email'
it_behaves_like 'it should show Gmail Actions View Merge request link'
it_behaves_like 'an unsubscribeable thread'
it_behaves_like 'appearance header and footer enabled'
it_behaves_like 'appearance header and footer not enabled'
it 'is sent as the merge request author' do
sender = subject.header[:from].addrs[0]
expect(sender.display_name).to eq(merge_request.author.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(project_merge_request_path(project, merge_request))
is_expected.to have_body_text('due to conflict.')
is_expected.to have_link(merge_request.to_reference, href: project_merge_request_url(merge_request.target_project, merge_request))
is_expected.to have_text_part_content(assignee.name)
is_expected.to have_text_part_content(reviewer.name)
end
end
end
describe '#closed_merge_request_email' do
subject { Notify.closed_merge_request_email(recipient.id, merge_request.id, current_user.id) }
......@@ -131,13 +162,13 @@ RSpec.describe Emails::MergeRequests do
it "has required details" do
aggregate_failures do
expect(subject).to have_content title
expect(subject).to have_content merge_request.to_reference
expect(subject).to have_content current_user.name
expect(subject.html_part).to have_content(assignee.name)
expect(subject.text_part).to have_content(assignee.name)
expect(subject.html_part).to have_content(reviewer.name)
expect(subject.text_part).to have_content(reviewer.name)
is_expected.to have_content(title)
is_expected.to have_content(merge_request.to_reference)
is_expected.to have_content(current_user.name)
is_expected.to have_text_part_content(assignee.name)
is_expected.to have_html_part_content(assignee.name)
is_expected.to have_text_part_content(reviewer.name)
is_expected.to have_html_part_content(reviewer.name)
end
end
end
......
......@@ -464,44 +464,6 @@ RSpec.describe Notify do
end
end
describe 'that are unmergeable' do
let_it_be(:merge_request) do
create(:merge_request, :conflict,
source_project: project,
target_project: project,
author: current_user,
assignees: [assignee],
description: 'Awesome description')
end
subject { described_class.merge_request_unmergeable_email(recipient.id, merge_request.id) }
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_behaves_like 'appearance header and footer enabled'
it_behaves_like 'appearance header and footer not enabled'
it 'is sent as the merge request author' do
sender = subject.header[:from].addrs[0]
expect(sender.display_name).to eq(merge_request.author.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(project_merge_request_path(project, merge_request))
is_expected.to have_body_text('due to conflict.')
is_expected.to have_link(merge_request.to_reference, href: project_merge_request_url(merge_request.target_project, merge_request))
end
end
end
shared_examples 'a push to an existing merge request' do
let(:push_user) { create(:user) }
......
# frozen_string_literal: true
RSpec::Matchers.define :have_text_part_content do |expected|
match do |actual|
@actual = actual.text_part.body.to_s
expect(@actual).to include(expected)
end
diffable
end
RSpec::Matchers.define :have_html_part_content do |expected|
match do |actual|
@actual = actual.html_part.body.to_s
expect(@actual).to include(expected)
end
diffable
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