From 46e4e8f4dc968b7173aa37bb3e3bb944e5d63e10 Mon Sep 17 00:00:00 2001 From: "micael.bergeron" Date: Tue, 12 Sep 2017 13:42:40 -0400 Subject: [PATCH] changed InlineDiffMarker to make it html_safe its output updated the spec --- app/views/projects/diffs/_file_header.html.haml | 2 +- lib/gitlab/diff/inline_diff_marker.rb | 3 ++- spec/helpers/diff_helper_spec.rb | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/views/projects/diffs/_file_header.html.haml b/app/views/projects/diffs/_file_header.html.haml index d5b9f328098..73c316472e3 100644 --- a/app/views/projects/diffs/_file_header.html.haml +++ b/app/views/projects/diffs/_file_header.html.haml @@ -17,7 +17,7 @@ = blob_icon diff_file.b_mode, diff_file.file_path - if diff_file.renamed_file? - - old_path, new_path = mark_inline_diffs(diff_file.old_path, diff_file.new_path).map(&:html_safe) + - old_path, new_path = mark_inline_diffs(diff_file.old_path, diff_file.new_path) %strong.file-title-name.has-tooltip{ data: { title: diff_file.old_path, container: 'body' } } = old_path → diff --git a/lib/gitlab/diff/inline_diff_marker.rb b/lib/gitlab/diff/inline_diff_marker.rb index 919965100ae..010b4be7b40 100644 --- a/lib/gitlab/diff/inline_diff_marker.rb +++ b/lib/gitlab/diff/inline_diff_marker.rb @@ -2,9 +2,10 @@ module Gitlab module Diff class InlineDiffMarker < Gitlab::StringRangeMarker def mark(line_inline_diffs, mode: nil) - super(line_inline_diffs) do |text, left:, right:| + mark = super(line_inline_diffs) do |text, left:, right:| %{#{text}} end + mark.html_safe end private diff --git a/spec/helpers/diff_helper_spec.rb b/spec/helpers/diff_helper_spec.rb index 0deea0ff6a3..f9c31ac61d8 100644 --- a/spec/helpers/diff_helper_spec.rb +++ b/spec/helpers/diff_helper_spec.rb @@ -136,9 +136,9 @@ describe DiffHelper do marked_old_line, marked_new_line = mark_inline_diffs(old_line, new_line) expect(marked_old_line).to eq(%q{abc 'def'}) - expect(marked_old_line).not_to be_html_safe + expect(marked_old_line).to be_html_safe expect(marked_new_line).to eq(%q{abc "def"}) - expect(marked_new_line).not_to be_html_safe + expect(marked_new_line).to be_html_safe end end