2018-03-17 18:26:18 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Gitlab::ImportExport::UploadsRestorer do
|
|
|
|
describe 'bundle a project Git repo' do
|
|
|
|
let(:export_path) { "#{Dir.tmpdir}/uploads_saver_spec" }
|
2018-03-27 19:54:05 +05:30
|
|
|
let(:shared) { project.import_export_shared }
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
before do
|
|
|
|
allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path)
|
|
|
|
FileUtils.mkdir_p(File.join(shared.export_path, 'uploads/random'))
|
2018-11-20 20:47:30 +05:30
|
|
|
FileUtils.touch(File.join(shared.export_path, 'uploads/random', 'dummy.txt'))
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
after do
|
|
|
|
FileUtils.rm_rf(export_path)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'legacy storage' do
|
2018-03-27 19:54:05 +05:30
|
|
|
let(:project) { create(:project, :legacy_storage) }
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
subject(:restorer) { described_class.new(project: project, shared: shared) }
|
|
|
|
|
|
|
|
it 'saves the uploads successfully' do
|
|
|
|
expect(restorer.restore).to be true
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'copies the uploads to the project path' do
|
|
|
|
subject.restore
|
|
|
|
|
2018-11-20 20:47:30 +05:30
|
|
|
expect(project.uploads.map { |u| u.build_uploader.filename }).to include('dummy.txt')
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'hashed storage' do
|
2018-03-27 19:54:05 +05:30
|
|
|
let(:project) { create(:project) }
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
subject(:restorer) { described_class.new(project: project, shared: shared) }
|
|
|
|
|
|
|
|
it 'saves the uploads successfully' do
|
|
|
|
expect(restorer.restore).to be true
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'copies the uploads to the project path' do
|
|
|
|
subject.restore
|
|
|
|
|
2018-11-20 20:47:30 +05:30
|
|
|
expect(project.uploads.map { |u| u.build_uploader.filename }).to include('dummy.txt')
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|