2019-03-30 03:23:56 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-05-08 19:50:23 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-06-29 00:13:10 -04:00
|
|
|
describe BlobViewer::ServerSide do
|
2017-05-08 19:50:23 -04:00
|
|
|
include FakeBlobHelpers
|
|
|
|
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { build(:project) }
|
2017-05-08 19:50:23 -04:00
|
|
|
|
|
|
|
let(:viewer_class) do
|
|
|
|
Class.new(BlobViewer::Base) do
|
|
|
|
include BlobViewer::ServerSide
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
subject { viewer_class.new(blob) }
|
|
|
|
|
|
|
|
describe '#prepare!' do
|
|
|
|
let(:blob) { fake_blob(path: 'file.txt') }
|
|
|
|
|
|
|
|
it 'loads all blob data' do
|
|
|
|
expect(blob).to receive(:load_all_data!)
|
|
|
|
|
|
|
|
subject.prepare!
|
|
|
|
end
|
|
|
|
end
|
2017-05-12 15:43:06 -04:00
|
|
|
|
|
|
|
describe '#render_error' do
|
|
|
|
context 'when the blob is stored externally' do
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { build(:project, lfs_enabled: true) }
|
2017-05-12 15:43:06 -04:00
|
|
|
|
|
|
|
let(:blob) { fake_blob(path: 'file.pdf', lfs: true) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
allow(Gitlab.config.lfs).to receive(:enabled).and_return(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'return :server_side_but_stored_externally' do
|
|
|
|
expect(subject.render_error).to eq(:server_side_but_stored_externally)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-05-08 19:50:23 -04:00
|
|
|
end
|