diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-26 21:09:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-26 21:09:24 +0300 |
commit | 619d0b6922a6cf95d291fbbf5fa3d09e772a1ea8 (patch) | |
tree | fb8f8e036cec1b32166206bb5102af6c5dca8cfe /spec/services/projects/import_export/export_service_spec.rb | |
parent | 17ab40ca089e1aef61a83f77ab6df62a72f6ce06 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/projects/import_export/export_service_spec.rb')
-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) } |