diff options
author | James Lopez <james@jameslopez.es> | 2018-07-11 12:36:59 +0300 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2018-07-11 12:36:59 +0300 |
commit | 3a114c2d119a9d0a7a8a9c85a6c7ec405f3a0f12 (patch) | |
tree | 6abb5e663805b9c5c0bfc0509f5cbf5809e92ef3 /spec/lib | |
parent | 7c9f21683ce2eea8f1f901d81b32ad775d7f9ba6 (diff) |
fix specs
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/import_export/uploads_manager_spec.rb | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/spec/lib/gitlab/import_export/uploads_manager_spec.rb b/spec/lib/gitlab/import_export/uploads_manager_spec.rb index 33c90c3a785..ffb8d140f32 100644 --- a/spec/lib/gitlab/import_export/uploads_manager_spec.rb +++ b/spec/lib/gitlab/import_export/uploads_manager_spec.rb @@ -17,7 +17,7 @@ describe Gitlab::ImportExport::UploadsManager do FileUtils.rm_rf(shared.export_path) end - describe '#copy' do + describe '#save' do context 'when the project has uploads locally stored' do let(:upload) { create(:upload, :issuable_upload, :with_file, model: project) } @@ -26,13 +26,15 @@ describe Gitlab::ImportExport::UploadsManager do end it 'does not cause errors' do - manager.copy + manager.save expect(shared.errors).to be_empty end it 'copies the file in the correct location when there is an upload' do - manager.copy + manager.save + + puts exported_file_path expect(File).to exist(exported_file_path) end @@ -52,10 +54,29 @@ describe Gitlab::ImportExport::UploadsManager do expect(fake_uri).to receive(:open).and_return(StringIO.new('File content')) expect(URI).to receive(:parse).and_return(fake_uri) - manager.copy + manager.save expect(File.read(exported_file_path)).to eq('File content') end end + + describe '#restore' do + context 'using object storage' do + before do + stub_feature_flags(import_export_object_storage: true) + stub_uploads_object_storage(FileUploader) + + FileUtils.mkdir_p(File.join(shared.export_path, 'uploads/random')) + FileUtils.touch(File.join(shared.export_path, 'uploads/random', "dummy.txt")) + end + + it 'downloads the file to include in an archive' do + manager.restore + + expect(project.uploads.size).to eq(1) + expect(project.uploads.first.build_uploader.filename).to eq('dummy.txt') + end + end + end end end |