From a91101d0ac19e33b0f26acaa4c2f1207789641fb Mon Sep 17 00:00:00 2001 From: "micael.bergeron" Date: Mon, 11 Sep 2017 11:17:59 -0400 Subject: [PATCH] rework the html_safe not to use haml's auto escaping add feature test for inline diff in file header --- app/views/projects/diffs/_file_header.html.haml | 6 +++--- ...caped-html-for-the-inline-diff-in-the-header.yml | 5 +++++ spec/features/projects/diffs/diff_show_spec.rb | 13 +++++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 changelogs/unreleased/37576-renamed-files-have-escaped-html-for-the-inline-diff-in-the-header.yml diff --git a/app/views/projects/diffs/_file_header.html.haml b/app/views/projects/diffs/_file_header.html.haml index 466a628b746..d5b9f328098 100644 --- a/app/views/projects/diffs/_file_header.html.haml +++ b/app/views/projects/diffs/_file_header.html.haml @@ -17,12 +17,12 @@ = 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) + - old_path, new_path = mark_inline_diffs(diff_file.old_path, diff_file.new_path).map(&:html_safe) %strong.file-title-name.has-tooltip{ data: { title: diff_file.old_path, container: 'body' } } - != old_path + = old_path → %strong.file-title-name.has-tooltip{ data: { title: diff_file.new_path, container: 'body' } } - != new_path + = new_path - else %strong.file-title-name.has-tooltip{ data: { title: diff_file.file_path, container: 'body' } } = diff_file.file_path diff --git a/changelogs/unreleased/37576-renamed-files-have-escaped-html-for-the-inline-diff-in-the-header.yml b/changelogs/unreleased/37576-renamed-files-have-escaped-html-for-the-inline-diff-in-the-header.yml new file mode 100644 index 00000000000..8c328eb0950 --- /dev/null +++ b/changelogs/unreleased/37576-renamed-files-have-escaped-html-for-the-inline-diff-in-the-header.yml @@ -0,0 +1,5 @@ +--- +title: Fix the diff file header from being html escaped for renamed files. +merge_request: 14121 +author: +type: fixed diff --git a/spec/features/projects/diffs/diff_show_spec.rb b/spec/features/projects/diffs/diff_show_spec.rb index bc102895aaf..a6f52c9ef58 100644 --- a/spec/features/projects/diffs/diff_show_spec.rb +++ b/spec/features/projects/diffs/diff_show_spec.rb @@ -108,6 +108,19 @@ feature 'Diff file viewer', :js do end end + context 'renamed file' do + before do + visit_commit('6907208d755b60ebeacb2e9dfea74c92c3449a1f') + end + + it 'shows the filename with diff highlight' do + within('.file-header-content') do + expect(page).to have_css('.idiff.left.right.deletion') + expect(page).to have_content('files/js/commit.coffee') + end + end + end + context 'binary file that appears to be text in the first 1024 bytes' do before do # The file we're visiting is smaller than 10 KB and we want it collapsed