diff options
Diffstat (limited to 'spec/lib/bulk_imports/importers/group_importer_spec.rb')
-rw-r--r-- | spec/lib/bulk_imports/importers/group_importer_spec.rb | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/spec/lib/bulk_imports/importers/group_importer_spec.rb b/spec/lib/bulk_imports/importers/group_importer_spec.rb index 95ac5925c97..95dca7fc486 100644 --- a/spec/lib/bulk_imports/importers/group_importer_spec.rb +++ b/spec/lib/bulk_imports/importers/group_importer_spec.rb @@ -18,12 +18,12 @@ RSpec.describe BulkImports::Importers::GroupImporter do subject { described_class.new(bulk_import_entity) } before do + allow(Gitlab).to receive(:ee?).and_return(false) allow(BulkImports::Pipeline::Context).to receive(:new).and_return(context) - stub_http_requests end describe '#execute' do - it "starts the entity and run its pipelines" do + it 'starts the entity and run its pipelines' do expect(bulk_import_entity).to receive(:start).and_call_original expect_to_run_pipeline BulkImports::Groups::Pipelines::GroupPipeline, context: context expect_to_run_pipeline BulkImports::Groups::Pipelines::SubgroupEntitiesPipeline, context: context @@ -32,6 +32,18 @@ RSpec.describe BulkImports::Importers::GroupImporter do expect(bulk_import_entity.reload).to be_finished end + + context 'when failed' do + let(:bulk_import_entity) { create(:bulk_import_entity, :failed, bulk_import: bulk_import) } + + it 'does not transition entity to finished state' do + allow(bulk_import_entity).to receive(:start!) + + subject.execute + + expect(bulk_import_entity.reload).to be_failed + end + end end def expect_to_run_pipeline(klass, context:) @@ -39,18 +51,4 @@ RSpec.describe BulkImports::Importers::GroupImporter do expect(pipeline).to receive(:run).with(context) end end - - def stub_http_requests - double_response = double( - code: 200, - success?: true, - parsed_response: {}, - headers: {} - ) - - allow_next_instance_of(BulkImports::Clients::Http) do |client| - allow(client).to receive(:get).and_return(double_response) - allow(client).to receive(:post).and_return(double_response) - end - end end |