diff options
Diffstat (limited to 'spec/services/bulk_imports/export_service_spec.rb')
-rw-r--r-- | spec/services/bulk_imports/export_service_spec.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/services/bulk_imports/export_service_spec.rb b/spec/services/bulk_imports/export_service_spec.rb new file mode 100644 index 00000000000..2414f7c5ca7 --- /dev/null +++ b/spec/services/bulk_imports/export_service_spec.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe BulkImports::ExportService do + let_it_be(:group) { create(:group) } + let_it_be(:user) { create(:user) } + + before do + group.add_owner(user) + end + + subject { described_class.new(portable: group, user: user) } + + describe '#execute' do + it 'schedules RelationExportWorker for each top level relation' do + expect(subject).to receive(:execute).and_return(ServiceResponse.success).and_call_original + top_level_relations = BulkImports::FileTransfer.config_for(group).portable_relations + + top_level_relations.each do |relation| + expect(BulkImports::RelationExportWorker) + .to receive(:perform_async) + .with(user.id, group.id, group.class.name, relation) + end + + subject.execute + end + + context 'when exception occurs' do + it 'does not schedule RelationExportWorker' do + service = described_class.new(portable: nil, user: user) + + expect(service) + .to receive(:execute) + .and_return(ServiceResponse.error(message: 'Gitlab::ImportExport::Error', http_status: :unprocessible_entity)) + .and_call_original + expect(BulkImports::RelationExportWorker).not_to receive(:perform_async) + + service.execute + end + end + end +end |