Welcome to mirror list, hosted at ThFree Co, Russian Federation.

group_importer_spec.rb « importers « bulk_imports « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7fec3b79179c8039af5a1eb72d799fca12a8eca0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# 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(Gitlab).to receive(:ee?).and_return(false)
    allow(BulkImports::Pipeline::Context).to receive(:new).and_return(context)
  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
end