Commit f318a143 authored by Sean McGivern's avatar Sean McGivern

Merge branch '58065-uniform-html-txt-email' into 'master'

Make HTML and text emails for new issues uniform and add the mail to mailer previews

Closes #58065

See merge request gitlab-org/gitlab-ce!29886
parents 671d7cdc df4c1a75
...@@ -5,27 +5,21 @@ ...@@ -5,27 +5,21 @@
- discussion = note.discussion if note.part_of_discussion? - discussion = note.discussion if note.part_of_discussion?
- if discussion %p{ style: "color: #777777;" }
%p{ style: "color: #777777;" } = succeed ':' do
= succeed ':' do = link_to note.author_name, user_url(note.author)
= link_to note.author_name, user_url(note.author) - if discussion.nil?
commented
- else
- if discussion.new_discussion?
started a new
- else
commented on a
- if discussion&.diff_discussion? - if discussion&.diff_discussion?
- if discussion.new_discussion? discussion on #{link_to(discussion.file_path, target_url)}
started a new discussion
- else
commented on a discussion
on #{link_to discussion.file_path, target_url}
- else - else
- if discussion.new_discussion? = link_to 'discussion', target_url
started a new discussion
- else
commented on a #{link_to 'discussion', target_url}
- elsif Gitlab::CurrentSettings.email_author_in_body
%p.details
#{link_to note.author_name, user_url(note.author)} commented:
- if discussion&.diff_discussion? && discussion.on_text? - if discussion&.diff_discussion? && discussion.on_text?
= content_for :head do = content_for :head do
......
<% note = local_assigns.fetch(:note, @note) -%> <% note = local_assigns.fetch(:note, @note) -%>
<% diff_limit = local_assigns.fetch(:diff_limit, nil) -%> <% diff_limit = local_assigns.fetch(:diff_limit, nil) -%>
<% target_url = local_assigns.fetch(:target_url, @target_url) -%> <% target_url = local_assigns.fetch(:target_url, @target_url) -%>
<% discussion = note.discussion if note.part_of_discussion? -%>
<% discussion = note.discussion if note.part_of_discussion? -%> <%= sanitize_name(note.author_name) -%>
<% if discussion && !discussion.individual_note? -%> <% if discussion.nil? -%>
<%= sanitize_name(note.author_name) -%> <%= 'commented' -%>:
<% else -%>
<% if discussion.new_discussion? -%> <% if discussion.new_discussion? -%>
<%= " started a new discussion" -%> <%= 'started a new discussion' -%>
<% else -%> <% else -%>
<%= " commented on a discussion" -%> <%= 'commented on a discussion' -%>
<% end -%> <% end -%>
<% if discussion.diff_discussion? -%> <% if discussion.diff_discussion? -%>
<%= " on #{discussion.file_path}" -%> <%= "on #{discussion.file_path}" -%>
<% end -%> <% end -%>
<%= ":" -%> <%= ':' -%>
<% if discussion.diff_discussion? || !discussion.new_discussion? -%> <%= " #{target_url}" -%>
<%= " #{target_url}" -%> <% end -%>
<% end -%>
<% elsif Gitlab::CurrentSettings.email_author_in_body -%>
<%= "#{sanitize_name(note.author_name)} commented:" -%>
<% end -%>
<% if discussion&.diff_discussion? && discussion.on_text? -%> <% if discussion&.diff_discussion? && discussion.on_text? -%>
<% discussion.truncated_diff_lines(highlight: false, diff_limit: diff_limit).each do |line| -%> <% discussion.truncated_diff_lines(highlight: false, diff_limit: diff_limit).each do |line| -%>
<%= "> #{line.text}\n" -%> <%= "> #{line.text}\n" -%>
......
- if Gitlab::CurrentSettings.email_author_in_body %p.details
%p.details #{link_to @issue.author_name, user_url(@issue.author)} created an issue:
#{link_to @issue.author_name, user_url(@issue.author)} created an issue:
- if @issue.assignees.any? - if @issue.assignees.any?
%p %p
......
New Issue was created. <%= sanitize_name(@issue.author_name) %> <%= 'created an issue:' %>
Issue <%= @issue.iid %>: <%= url_for(project_issue_url(@issue.project, @issue)) %> <% if @issue.assignees.any? -%>
Author: <%= sanitize_name(@issue.author_name) %> <%= assignees_label(@issue) %>
<%= assignees_label(@issue) %> <% end %>
<%= @issue.description %> <% if @issue.description -%>
<%= @issue.description %>
<% end %>
- if Gitlab::CurrentSettings.email_author_in_body
%p.details
#{link_to @merge_request.author_name, user_url(@merge_request.author)} created a merge request:
%p.details %p.details
= merge_path_description(@merge_request, '→') #{link_to @merge_request.author_name, user_url(@merge_request.author)} created a merge request:
- if @merge_request.assignees.any? %p
%p .branch
= merge_path_description(@merge_request, 'to')
.author
Author #{@merge_request.author_name}
.assignee
= assignees_label(@merge_request) = assignees_label(@merge_request)
.approvers
= render_if_exists 'notify/merge_request_approvers', presenter: @mr_presenter = render_if_exists 'notify/merge_request_approvers', presenter: @mr_presenter
- if @merge_request.description - if @merge_request.description
%div %div
......
New Merge Request <%= @merge_request.to_reference %> <%= @merge_request.author_name %> <%= 'created a merge request:' %> <%= url_for(project_merge_request_url(@merge_request.target_project, @merge_request)) %>
<%= url_for(project_merge_request_url(@merge_request.target_project, @merge_request)) %>
<%= merge_path_description(@merge_request, 'to') %> <%= merge_path_description(@merge_request, 'to') %>
Author: <%= @merge_request.author_name %> <%= 'Author' %>: <%= @merge_request.author_name %>
<%= assignees_label(@merge_request) %> <%= assignees_label(@merge_request) %>
<%= render_if_exists 'notify/merge_request_approvers', presenter: @mr_presenter %> <%= render_if_exists 'notify/merge_request_approvers', presenter: @mr_presenter %>
......
---
title: Always shows author of created issue/started discussion/comment in HTML body and text of email
merge_request: 29886
author: Frank van Rest
type: fixed
...@@ -99,15 +99,9 @@ describe Notify do ...@@ -99,15 +99,9 @@ describe Notify do
end end
end end
context 'when enabled email_author_in_body' do it 'contains a link to issue author' do
before do is_expected.to have_body_text(issue.author_name)
stub_application_setting(email_author_in_body: true) is_expected.to have_body_text 'created an issue:'
end
it 'contains a link to note author' do
is_expected.to have_body_text(issue.author_name)
is_expected.to have_body_text 'created an issue:'
end
end end
end end
...@@ -314,15 +308,9 @@ describe Notify do ...@@ -314,15 +308,9 @@ describe Notify do
end end
end end
context 'when enabled email_author_in_body' do it 'contains a link to merge request author' do
before do is_expected.to have_body_text merge_request.author_name
stub_application_setting(email_author_in_body: true) is_expected.to have_body_text 'created a merge request:'
end
it 'contains a link to note author' do
is_expected.to have_body_text merge_request.author_name
is_expected.to have_body_text 'created a merge request:'
end
end end
end end
...@@ -907,7 +895,9 @@ describe Notify do ...@@ -907,7 +895,9 @@ describe Notify do
end end
it 'contains an introduction' do it 'contains an introduction' do
is_expected.to have_body_text 'started a new discussion' issuable_url = "project_#{note.noteable_type.underscore}_url"
is_expected.to have_body_text "started a new <a href=\"#{public_send(issuable_url, project, note.noteable, anchor: "note_#{note.id}")}\">discussion</a>"
end end
context 'when a comment on an existing discussion' do context 'when a comment on an existing discussion' do
......
...@@ -281,18 +281,8 @@ shared_examples 'a note email' do ...@@ -281,18 +281,8 @@ shared_examples 'a note email' do
is_expected.to have_body_text note.note is_expected.to have_body_text note.note
end end
it 'does not contain note author' do it 'contains a link to note author' do
is_expected.not_to have_body_text note.author_name is_expected.to have_body_text note.author_name
end
context 'when enabled email_author_in_body' do
before do
stub_application_setting(email_author_in_body: true)
end
it 'contains a link to note author' do
is_expected.to have_body_text note.author_name
end
end end
end 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