diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
commit | 0653e08efd039a5905f3fa4f6e9cef9f5d2f799c (patch) | |
tree | 4dcc884cf6d81db44adae4aa99f8ec1233a41f55 /spec/models/bulk_imports/entity_spec.rb | |
parent | 744144d28e3e7fddc117924fef88de5d9674fe4c (diff) |
Add latest changes from gitlab-org/gitlab@14-3-stable-eev14.3.0-rc42
Diffstat (limited to 'spec/models/bulk_imports/entity_spec.rb')
-rw-r--r-- | spec/models/bulk_imports/entity_spec.rb | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/spec/models/bulk_imports/entity_spec.rb b/spec/models/bulk_imports/entity_spec.rb index 11a3e53dd16..c1cbe61885f 100644 --- a/spec/models/bulk_imports/entity_spec.rb +++ b/spec/models/bulk_imports/entity_spec.rb @@ -154,4 +154,57 @@ RSpec.describe BulkImports::Entity, type: :model do expect(described_class.all_human_statuses).to contain_exactly('created', 'started', 'finished', 'failed') end end + + describe '#pipelines' do + context 'when entity is group' do + it 'returns group pipelines' do + entity = build(:bulk_import_entity, :group_entity) + + expect(entity.pipelines.flatten).to include(BulkImports::Groups::Pipelines::GroupPipeline) + end + end + + context 'when entity is project' do + it 'returns project pipelines' do + entity = build(:bulk_import_entity, :project_entity) + + expect(entity.pipelines.flatten).to include(BulkImports::Projects::Pipelines::ProjectPipeline) + end + end + end + + describe '#create_pipeline_trackers!' do + context 'when entity is group' do + it 'creates trackers for group entity' do + entity = create(:bulk_import_entity, :group_entity) + entity.create_pipeline_trackers! + + expect(entity.trackers.count).to eq(BulkImports::Groups::Stage.pipelines.count) + expect(entity.trackers.map(&:pipeline_name)).to include(BulkImports::Groups::Pipelines::GroupPipeline.to_s) + end + end + + context 'when entity is project' do + it 'creates trackers for project entity' do + entity = create(:bulk_import_entity, :project_entity) + entity.create_pipeline_trackers! + + expect(entity.trackers.count).to eq(BulkImports::Projects::Stage.pipelines.count) + expect(entity.trackers.map(&:pipeline_name)).to include(BulkImports::Projects::Pipelines::ProjectPipeline.to_s) + end + end + end + + describe '#pipeline_exists?' do + let_it_be(:entity) { create(:bulk_import_entity, :group_entity) } + + it 'returns true when the given pipeline name exists in the pipelines list' do + expect(entity.pipeline_exists?(BulkImports::Groups::Pipelines::GroupPipeline)).to eq(true) + expect(entity.pipeline_exists?('BulkImports::Groups::Pipelines::GroupPipeline')).to eq(true) + end + + it 'returns false when the given pipeline name exists in the pipelines list' do + expect(entity.pipeline_exists?('BulkImports::Groups::Pipelines::InexistentPipeline')).to eq(false) + end + end end |