From 5dd2862195f00e19ee9dccc126d01a8d2c484de0 Mon Sep 17 00:00:00 2001 From: Felipe Artur Date: Thu, 9 Nov 2017 17:59:39 -0200 Subject: [PATCH] Fix image diff notes email --- app/views/notify/_note_email.html.haml | 11 ++++++++--- changelogs/unreleased/issue_39238.yml | 5 +++++ spec/mailers/notify_spec.rb | 20 +++++++++++++++++++- 3 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 changelogs/unreleased/issue_39238.yml diff --git a/app/views/notify/_note_email.html.haml b/app/views/notify/_note_email.html.haml index a80518f7986..3e36da31ea3 100644 --- a/app/views/notify/_note_email.html.haml +++ b/app/views/notify/_note_email.html.haml @@ -1,10 +1,15 @@ - discussion = @note.discussion if @note.part_of_discussion? +- diff_discussion = discussion&.diff_discussion? +- on_image = discussion.on_image? if diff_discussion + - if discussion + - phrase_end_char = on_image ? "." : ":" + %p.details - = succeed ':' do + = succeed phrase_end_char do = link_to @note.author_name, user_url(@note.author) - - if discussion.diff_discussion? + - if diff_discussion - if discussion.new_discussion? started a new discussion - else @@ -21,7 +26,7 @@ %p.details #{link_to @note.author_name, user_url(@note.author)} commented: -- if discussion&.diff_discussion? +- if diff_discussion && !on_image = content_for :head do = stylesheet_link_tag 'mailers/highlighted_diff_email' diff --git a/changelogs/unreleased/issue_39238.yml b/changelogs/unreleased/issue_39238.yml new file mode 100644 index 00000000000..75a4969ca9e --- /dev/null +++ b/changelogs/unreleased/issue_39238.yml @@ -0,0 +1,5 @@ +--- +title: Fix image diff notification email from showing wrong content +merge_request: +author: +type: fixed diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index c832cee965b..f942a22b6d1 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -783,7 +783,25 @@ describe Notify do shared_examples 'an email for a note on a diff discussion' do |model| let(:note) { create(model, author: note_author) } - it "includes diffs with character-level highlighting" do + context 'when note is on image' do + before do + allow_any_instance_of(DiffDiscussion).to receive(:on_image?).and_return(true) + end + + it 'does not include diffs with character-level highlighting' do + is_expected.not_to have_body_text '}' + end + + it 'ends the intro with a dot' do + is_expected.to have_body_text "#{note.diff_file.file_path}." + end + end + + it 'ends the intro with a colon' do + is_expected.to have_body_text "#{note.diff_file.file_path}:" + end + + it 'includes diffs with character-level highlighting' do is_expected.to have_body_text '}' end -- GitLab