diff options
Diffstat (limited to 'spec/services/projects/import_export')
-rw-r--r-- | spec/services/projects/import_export/export_service_spec.rb | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/spec/services/projects/import_export/export_service_spec.rb b/spec/services/projects/import_export/export_service_spec.rb index 906fef6edf5..ec1771e64c2 100644 --- a/spec/services/projects/import_export/export_service_spec.rb +++ b/spec/services/projects/import_export/export_service_spec.rb @@ -27,7 +27,7 @@ describe Projects::ImportExport::ExportService do end it 'saves the models' do - expect(Gitlab::ImportExport::ProjectTreeSaver).to receive(:new).and_call_original + expect(Gitlab::ImportExport::Project::TreeSaver).to receive(:new).and_call_original service.execute end @@ -91,10 +91,10 @@ describe Projects::ImportExport::ExportService do end it 'removes the remaining exported data' do - allow(shared).to receive(:export_path).and_return('whatever') + allow(shared).to receive(:archive_path).and_return('whatever') allow(FileUtils).to receive(:rm_rf) - expect(FileUtils).to receive(:rm_rf).with(shared.export_path) + expect(FileUtils).to receive(:rm_rf).with(shared.archive_path) end it 'notifies the user' do @@ -121,10 +121,10 @@ describe Projects::ImportExport::ExportService do end it 'removes the remaining exported data' do - allow(shared).to receive(:export_path).and_return('whatever') + allow(shared).to receive(:archive_path).and_return('whatever') allow(FileUtils).to receive(:rm_rf) - expect(FileUtils).to receive(:rm_rf).with(shared.export_path) + expect(FileUtils).to receive(:rm_rf).with(shared.archive_path) end it 'notifies the user' do @@ -142,6 +142,21 @@ describe Projects::ImportExport::ExportService do end end + context 'when one of the savers fail unexpectedly' do + let(:archive_path) { shared.archive_path } + + before do + allow(service).to receive_message_chain(:uploads_saver, :save).and_return(false) + end + + it 'removes the remaining exported data' do + expect { service.execute }.to raise_error(Gitlab::ImportExport::Error) + + expect(project.import_export_upload).to be_nil + expect(File.exist?(shared.archive_path)).to eq(false) + end + end + context 'when user does not have admin_project permission' do let!(:another_user) { create(:user) } |