Commit 38ed96e9 authored by hhoopes's avatar hhoopes Committed by Sean McGivern

Add diff hunks to notification emails on MR

Added diff hunks to notification emails of messages on merge requests. This
provides code context to the note. Uses existing template for formatting
a diff for email (from repository push notifications).
parent 838c1aad
...@@ -797,6 +797,7 @@ entry. ...@@ -797,6 +797,7 @@ entry.
## 8.11.0 (2016-08-22) ## 8.11.0 (2016-08-22)
- Use test coverage value from the latest successful pipeline in badge. !5862 - Use test coverage value from the latest successful pipeline in badge. !5862
- Add git diff context to notifications of new notes on merge requests !5855 (hoopes)
- Add test coverage report badge. !5708 - Add test coverage report badge. !5708
- Remove the http_parser.rb dependency by removing the tinder gem. !5758 (tbalthazar) - Remove the http_parser.rb dependency by removing the tinder gem. !5758 (tbalthazar)
- Add Koding (online IDE) integration - Add Koding (online IDE) integration
......
= content_for :head do
= stylesheet_link_tag 'mailers/highlighted_diff_email'
- if @note.diff_note? && @note.diff_file - if @note.diff_note? && @note.diff_file
%p.details %p.details
New comment on diff for New comment on diff for
= link_to @note.diff_file.file_path, @target_url = link_to @note.diff_file.file_path, @target_url
\: \:
.diff-content.code.js-syntax-highlight
%table
- Discussion.new([@note]).truncated_diff_lines.each do |line|
= render "projects/diffs/line", line: line, diff_file: @note.diff_file, plain: true
= render 'note_message' = render 'note_message'
= content_for :head do = content_for :head do
= stylesheet_link_tag 'mailers/repository_push_email' = stylesheet_link_tag 'mailers/highlighted_diff_email'
%h3 %h3
#{@message.author_name} #{@message.action_name} #{@message.ref_type} #{@message.ref_name} #{@message.author_name} #{@message.action_name} #{@message.ref_type} #{@message.ref_name}
......
...@@ -580,9 +580,11 @@ describe Notify do ...@@ -580,9 +580,11 @@ describe Notify do
let(:note_author) { create(:user, name: 'author_name') } let(:note_author) { create(:user, name: 'author_name') }
let(:note) { create(:note, project: project, author: note_author) } let(:note) { create(:note, project: project, author: note_author) }
before :each do before do |example|
unless example.metadata[:skip_before]
allow(Note).to receive(:find).with(note.id).and_return(note) allow(Note).to receive(:find).with(note.id).and_return(note)
end end
end
shared_examples 'a note email' do shared_examples 'a note email' do
it_behaves_like 'it should have Gmail Actions links' it_behaves_like 'it should have Gmail Actions links'
...@@ -663,6 +665,19 @@ describe Notify do ...@@ -663,6 +665,19 @@ describe Notify do
end end
end end
describe "on a merge request with diffs", :skip_before do
let(:merge_request) { create(:merge_request_with_diffs) }
let(:note_with_diff) {create(:diff_note_on_merge_request)}
before(:each) { allow(note_with_diff).to receive(:noteable).and_return(merge_request) }
subject { Notify.note_merge_request_email(recipient.id, note_with_diff.id) }
it 'includes diffs with character-level highlighting' do
expected_line_text = Discussion.new([note_with_diff]).truncated_diff_lines.first.text
is_expected.to have_body_text expected_line_text
end
end
describe 'on an issue' do describe 'on an issue' do
let(:issue) { create(:issue, project: project) } let(:issue) { create(:issue, project: project) }
let(:note_on_issue_path) { namespace_project_issue_path(project.namespace, project, issue, anchor: "note_#{note.id}") } let(:note_on_issue_path) { namespace_project_issue_path(project.namespace, project, issue, anchor: "note_#{note.id}") }
......
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