summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClement Ho <ClemMakesApps@gmail.com>2017-09-18 16:53:59 -0500
committerClement Ho <ClemMakesApps@gmail.com>2017-09-18 16:53:59 -0500
commitd22a8b2bc2a23f09bc2243e3e5982665090ee60e (patch)
tree099635d4cee436f9d7248d81613497e492041ef7
parent1b0b19939b8d5b37ae283451fc9977d8f85730ed (diff)
downloadgitlab-ce-d22a8b2bc2a23f09bc2243e3e5982665090ee60e.tar.gz
Add test for view file links
-rw-r--r--app/views/projects/diffs/_file.html.haml6
-rw-r--r--spec/features/projects/diffs/diff_show_spec.rb14
2 files changed, 19 insertions, 1 deletions
diff --git a/app/views/projects/diffs/_file.html.haml b/app/views/projects/diffs/_file.html.haml
index 179a115bb89..227aa372717 100644
--- a/app/views/projects/diffs/_file.html.haml
+++ b/app/views/projects/diffs/_file.html.haml
@@ -1,5 +1,8 @@
- environment = local_assigns.fetch(:environment, nil)
- file_hash = hexdigest(diff_file.file_path)
+- image_diff = diff_file.rich_viewer && diff_file.rich_viewer.partial_name == 'image'
+- image_replaced = diff_file.old_content_sha && diff_file.old_content_sha != diff_file.content_sha
+
.diff-file.file-holder{ id: file_hash, data: diff_file_html_data(project, diff_file.file_path, diff_file.content_sha) }
.js-file-title.file-title-flex-parent
.file-header-content
@@ -17,7 +20,8 @@
= edit_blob_link(@merge_request.source_project, @merge_request.source_branch, diff_file.new_path,
blob: blob, link_opts: link_opts)
- - if diff_file.rich_viewer && diff_file.rich_viewer.partial_name == 'image' && diff_file.old_content_sha
+
+ - if image_diff && image_replaced
= view_file_button(diff_file.old_content_sha, diff_file.old_path, project, true)
= view_file_button(diff_file.content_sha, diff_file.file_path, project)
diff --git a/spec/features/projects/diffs/diff_show_spec.rb b/spec/features/projects/diffs/diff_show_spec.rb
index a6f52c9ef58..43bb54a434c 100644
--- a/spec/features/projects/diffs/diff_show_spec.rb
+++ b/spec/features/projects/diffs/diff_show_spec.rb
@@ -71,6 +71,20 @@ feature 'Diff file viewer', :js do
expect(page).to have_css('img[alt="files/images/6049019_460s.jpg"]')
end
end
+
+ it 'shows view replaced and view file links' do
+ expect(page.all('.file-actions a').length).to eq 2
+ end
+ end
+
+ context 'Image file added' do
+ before do
+ visit_commit('33f3729a45c02fc67d00adb1b8bca394b0e761d9')
+ end
+
+ it 'shows view file link ' do
+ expect(page.all('.file-actions a').length).to eq 1
+ end
end
context 'ISO file (stored in LFS)' do