blob: 864fd8d72fa2c97f41220bb621bbf5c1165c0bcc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::ImportExport::UploadsRestorer do
describe 'bundle a project Git repo' do
let(:export_path) { "#{Dir.tmpdir}/uploads_saver_spec" }
let(:shared) { project.import_export_shared }
before do
allow_next_instance_of(Gitlab::ImportExport) do |instance|
allow(instance).to receive(:storage_path).and_return(export_path)
end
FileUtils.mkdir_p(File.join(shared.export_path, 'uploads/random'))
FileUtils.touch(File.join(shared.export_path, 'uploads/random', 'dummy.txt'))
end
after do
FileUtils.rm_rf(export_path)
end
describe 'legacy storage' do
let(:project) { create(:project, :legacy_storage) }
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
expect(project.uploads.map { |u| u.retrieve_uploader.filename }).to include('dummy.txt')
end
end
describe 'hashed storage' do
let(:project) { create(:project) }
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
expect(project.uploads.map { |u| u.retrieve_uploader.filename }).to include('dummy.txt')
end
end
end
end
|