Commit b5ee56e5 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'sh-import-export-check-result' into 'master'

Fix import/export not checking upload result

See merge request gitlab-org/gitlab!78905
parents bb6c94a5 b67a5b5a
......@@ -47,8 +47,7 @@ module Projects
end
def save_all!
if save_exporters
Gitlab::ImportExport::Saver.save(exportable: project, shared: shared)
if save_exporters && save_export_archive
notify_success
else
notify_error!
......@@ -59,6 +58,10 @@ module Projects
exporters.all?(&:save)
end
def save_export_archive
Gitlab::ImportExport::Saver.save(exportable: project, shared: shared)
end
def exporters
[
version_saver, avatar_saver, project_tree_saver, uploads_saver,
......
......@@ -20,7 +20,7 @@ RSpec.describe Projects::ImportExport::ExportService do
end
it 'succeeds' do
expect(Gitlab::ImportExport::Saver).to receive(:save).with(exportable: project_template, shared: shared)
expect(Gitlab::ImportExport::Saver).to receive(:save).with(exportable: project_template, shared: shared).and_return(true)
subject
end
......@@ -32,7 +32,7 @@ RSpec.describe Projects::ImportExport::ExportService do
end
it 'succeeds' do
expect(Gitlab::ImportExport::Saver).to receive(:save).with(exportable: project_template, shared: shared)
expect(Gitlab::ImportExport::Saver).to receive(:save).with(exportable: project_template, shared: shared).and_return(true)
subject
end
......
......@@ -54,6 +54,8 @@ module Gitlab
File.open(archive_file) { |file| upload.export_file = file }
upload.save!
true
end
def error_message
......
......@@ -93,11 +93,23 @@ RSpec.describe Projects::ImportExport::ExportService do
end
it 'saves the project in the file system' do
expect(Gitlab::ImportExport::Saver).to receive(:save).with(exportable: project, shared: shared)
expect(Gitlab::ImportExport::Saver).to receive(:save).with(exportable: project, shared: shared).and_return(true)
service.execute
end
context 'when the upload fails' do
before do
expect(Gitlab::ImportExport::Saver).to receive(:save).with(exportable: project, shared: shared).and_return(false)
end
it 'notifies the user of an error' do
expect(service).to receive(:notify_error).and_call_original
expect { service.execute }.to raise_error(Gitlab::ImportExport::Error)
end
end
it 'calls the after export strategy' do
expect(after_export_strategy).to receive(:execute)
......@@ -107,6 +119,7 @@ RSpec.describe Projects::ImportExport::ExportService do
context 'when after export strategy fails' do
before do
allow(after_export_strategy).to receive(:execute).and_return(false)
expect(Gitlab::ImportExport::Saver).to receive(:save).with(exportable: project, shared: shared).and_return(true)
end
after do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment