diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-05-08 18:50:23 -0500 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-05-10 20:07:04 -0500 |
commit | 08706f683725dcfbda1708ddf079347d989fbef1 (patch) | |
tree | 91cbd54eac137206b85908361ceee41ae9671102 /spec/models/blob_spec.rb | |
parent | 62c93ab91218daf176ccbfc1622a6f3c58f1ad82 (diff) | |
download | gitlab-ce-08706f683725dcfbda1708ddf079347d989fbef1.tar.gz |
Implement auxiliary blob viewers
Diffstat (limited to 'spec/models/blob_spec.rb')
-rw-r--r-- | spec/models/blob_spec.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/spec/models/blob_spec.rb b/spec/models/blob_spec.rb index f84c6b48173..f19e1af65a6 100644 --- a/spec/models/blob_spec.rb +++ b/spec/models/blob_spec.rb @@ -271,6 +271,52 @@ describe Blob do end end + describe '#auxiliary_viewer' do + context 'when the blob has an external storage error' do + before do + project.lfs_enabled = false + end + + it 'returns nil' do + blob = fake_blob(path: 'LICENSE', lfs: true) + + expect(blob.auxiliary_viewer).to be_nil + end + end + + context 'when the blob is empty' do + it 'returns nil' do + blob = fake_blob(data: '') + + expect(blob.auxiliary_viewer).to be_nil + end + end + + context 'when the blob is stored externally' do + it 'returns a matching viewer' do + blob = fake_blob(path: 'LICENSE', lfs: true) + + expect(blob.auxiliary_viewer).to be_a(BlobViewer::License) + end + end + + context 'when the blob is binary' do + it 'returns nil' do + blob = fake_blob(path: 'LICENSE', binary: true) + + expect(blob.auxiliary_viewer).to be_nil + end + end + + context 'when the blob is text-based' do + it 'returns a matching text-based viewer' do + blob = fake_blob(path: 'LICENSE') + + expect(blob.auxiliary_viewer).to be_a(BlobViewer::License) + end + end + end + describe '#rendered_as_text?' do context 'when ignoring errors' do context 'when the simple viewer is text-based' do |