diff options
author | Stan Hu <stanhu@gmail.com> | 2017-05-11 12:40:44 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2017-05-11 12:40:44 -0700 |
commit | e3bac7dffe87a6e5adb1b51700acedba09420515 (patch) | |
tree | 3cad0696bdfeb79609c0442f79708fbbed2d93f1 /spec/models/blob_spec.rb | |
parent | f4b6bc06da18bce9553032463ca2012d7cad7268 (diff) | |
parent | e7e132529bff3af38175076b84c818b6dea4b05f (diff) | |
download | gitlab-ce-sh-ajax-tests.tar.gz |
Merge branch 'master' into sh-ajax-testssh-ajax-tests
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 |