changed InlineDiffMarker to make it html_safe its output

updated the spec
This commit is contained in:
micael.bergeron 2017-09-12 13:42:40 -04:00
parent a91101d0ac
commit 46e4e8f4dc
3 changed files with 5 additions and 4 deletions

View File

@ -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
→

View File

@ -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:|
%{<span class="#{html_class_names(left, right, mode)}">#{text}</span>}
end
mark.html_safe
end
private

View File

@ -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 <span class="idiff left right deletion">'def'</span>})
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 <span class="idiff left right addition">"def"</span>})
expect(marked_new_line).not_to be_html_safe
expect(marked_new_line).to be_html_safe
end
end