2017-08-24 21:30:12 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Gitlab::Git::LfsChanges do
|
|
|
|
let(:project) { create(:project, :repository) }
|
|
|
|
let(:newrev) { '54fcc214b94e78d7a41a9a8fe6d87a5e59500e51' }
|
|
|
|
let(:blob_object_id) { '0c304a93cb8430108629bbbcaa27db3343299bc0' }
|
|
|
|
|
|
|
|
subject { described_class.new(project.repository, newrev) }
|
|
|
|
|
2018-02-06 17:49:33 -05:00
|
|
|
describe '#new_pointers' do
|
|
|
|
shared_examples 'new pointers' do
|
|
|
|
it 'filters new objects to find lfs pointers' do
|
|
|
|
expect(subject.new_pointers(not_in: []).first.id).to eq(blob_object_id)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'limits new_objects using object_limit' do
|
|
|
|
expect(subject.new_pointers(object_limit: 1)).to eq([])
|
|
|
|
end
|
2017-08-24 21:30:12 -04:00
|
|
|
end
|
|
|
|
|
2018-02-06 17:49:33 -05:00
|
|
|
context 'with gitaly enabled' do
|
|
|
|
it_behaves_like 'new pointers'
|
2017-08-24 21:30:12 -04:00
|
|
|
end
|
|
|
|
|
2018-02-06 17:49:33 -05:00
|
|
|
context 'with gitaly disabled', :skip_gitaly_mock do
|
|
|
|
it_behaves_like 'new pointers'
|
2017-08-24 21:30:12 -04:00
|
|
|
|
2018-02-06 17:49:33 -05:00
|
|
|
it 'uses rev-list to find new objects' do
|
|
|
|
rev_list = double
|
|
|
|
allow(Gitlab::Git::RevList).to receive(:new).and_return(rev_list)
|
2017-08-24 21:30:12 -04:00
|
|
|
|
2018-02-06 17:49:33 -05:00
|
|
|
expect(rev_list).to receive(:new_objects).and_return([])
|
2017-08-24 21:30:12 -04:00
|
|
|
|
2018-02-06 17:49:33 -05:00
|
|
|
subject.new_pointers
|
|
|
|
end
|
2017-08-24 21:30:12 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-02-06 17:49:33 -05:00
|
|
|
describe '#all_pointers', :skip_gitaly_mock do
|
2017-08-24 21:30:12 -04:00
|
|
|
it 'uses rev-list to find all objects' do
|
|
|
|
rev_list = double
|
|
|
|
allow(Gitlab::Git::RevList).to receive(:new).and_return(rev_list)
|
2017-11-03 10:33:06 -04:00
|
|
|
allow(rev_list).to receive(:all_objects).and_yield([blob_object_id])
|
2017-08-24 21:30:12 -04:00
|
|
|
|
|
|
|
expect(Gitlab::Git::Blob).to receive(:batch_lfs_pointers).with(project.repository, [blob_object_id])
|
|
|
|
|
|
|
|
subject.all_pointers
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|