diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /spec/models/diff_viewer/image_spec.rb | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'spec/models/diff_viewer/image_spec.rb')
-rw-r--r-- | spec/models/diff_viewer/image_spec.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/models/diff_viewer/image_spec.rb b/spec/models/diff_viewer/image_spec.rb new file mode 100644 index 00000000000..e959a7d5eb2 --- /dev/null +++ b/spec/models/diff_viewer/image_spec.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe DiffViewer::Image do + describe '.can_render?' do + let(:diff_file) { double(Gitlab::Diff::File) } + let(:blob) { double(Gitlab::Git::Blob, binary_in_repo?: true, extension: 'png') } + + subject { described_class.can_render?(diff_file, verify_binary: false) } + + it 'returns false if both old and new blob are absent' do + allow(diff_file).to receive(:old_blob) { nil } + allow(diff_file).to receive(:new_blob) { nil } + + is_expected.to be_falsy + end + + it 'returns true if the old blob is present' do + allow(diff_file).to receive(:old_blob) { blob } + allow(diff_file).to receive(:new_blob) { nil } + + is_expected.to be_truthy + end + + it 'returns true if the new blob is present' do + allow(diff_file).to receive(:old_blob) { nil } + allow(diff_file).to receive(:new_blob) { blob } + + is_expected.to be_truthy + end + + it 'returns true if both old and new blobs are present' do + allow(diff_file).to receive(:old_blob) { blob } + allow(diff_file).to receive(:new_blob) { blob } + + is_expected.to be_truthy + end + end +end |