diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /spec/lib/bulk_imports/importers/group_importer_spec.rb | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'spec/lib/bulk_imports/importers/group_importer_spec.rb')
-rw-r--r-- | spec/lib/bulk_imports/importers/group_importer_spec.rb | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/spec/lib/bulk_imports/importers/group_importer_spec.rb b/spec/lib/bulk_imports/importers/group_importer_spec.rb new file mode 100644 index 00000000000..95ac5925c97 --- /dev/null +++ b/spec/lib/bulk_imports/importers/group_importer_spec.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe BulkImports::Importers::GroupImporter do + let(:user) { create(:user) } + let(:bulk_import) { create(:bulk_import) } + let(:bulk_import_entity) { create(:bulk_import_entity, bulk_import: bulk_import) } + let(:bulk_import_configuration) { create(:bulk_import_configuration, bulk_import: bulk_import) } + let(:context) do + BulkImports::Pipeline::Context.new( + current_user: user, + entity: bulk_import_entity, + configuration: bulk_import_configuration + ) + end + + subject { described_class.new(bulk_import_entity) } + + before do + 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 + 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 + + subject.execute + + expect(bulk_import_entity.reload).to be_finished + end + end + + def expect_to_run_pipeline(klass, context:) + expect_next_instance_of(klass) do |pipeline| + 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 |