diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-12 12:08:08 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-12 12:08:08 +0300 |
commit | 71d34aac9a0fae0507c265929767422391816b01 (patch) | |
tree | dedb769442c9576e2f44bf3c500b013beb9604d9 /spec/lib/bulk_imports | |
parent | 90726a8ccc9df6d9b5ff4f5e1eb31d015c1db8e2 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/bulk_imports')
4 files changed, 25 insertions, 23 deletions
diff --git a/spec/lib/bulk_imports/groups/pipelines/group_pipeline_spec.rb b/spec/lib/bulk_imports/groups/pipelines/group_pipeline_spec.rb index 39e782dc093..441a34b0c74 100644 --- a/spec/lib/bulk_imports/groups/pipelines/group_pipeline_spec.rb +++ b/spec/lib/bulk_imports/groups/pipelines/group_pipeline_spec.rb @@ -23,7 +23,7 @@ RSpec.describe BulkImports::Groups::Pipelines::GroupPipeline do let(:group_data) do { - 'name' => 'source_name', + 'name' => 'Source Group Name', 'full_path' => 'source/full/path', 'visibility' => 'private', 'project_creation_level' => 'developer', diff --git a/spec/lib/bulk_imports/groups/pipelines/subgroup_entities_pipeline_spec.rb b/spec/lib/bulk_imports/groups/pipelines/subgroup_entities_pipeline_spec.rb index e4a41428dd2..6949ac59948 100644 --- a/spec/lib/bulk_imports/groups/pipelines/subgroup_entities_pipeline_spec.rb +++ b/spec/lib/bulk_imports/groups/pipelines/subgroup_entities_pipeline_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' RSpec.describe BulkImports::Groups::Pipelines::SubgroupEntitiesPipeline do let_it_be(:user) { create(:user) } let_it_be(:group) { create(:group, path: 'group') } - let_it_be(:parent) { create(:group, name: 'imported-group', path: 'imported-group') } + let_it_be(:parent) { create(:group, name: 'Imported Group', path: 'imported-group') } let_it_be(:parent_entity) { create(:bulk_import_entity, destination_namespace: parent.full_path, group: parent) } let_it_be(:tracker) { create(:bulk_import_tracker, entity: parent_entity) } let_it_be(:context) { BulkImports::Pipeline::Context.new(tracker) } @@ -14,8 +14,8 @@ RSpec.describe BulkImports::Groups::Pipelines::SubgroupEntitiesPipeline do let(:extracted_data) do BulkImports::Pipeline::ExtractedData.new(data: { - 'name' => 'subgroup', - 'full_path' => 'parent/subgroup' + 'path' => 'sub-group', + 'full_path' => 'parent/sub-group' }) end @@ -33,9 +33,9 @@ RSpec.describe BulkImports::Groups::Pipelines::SubgroupEntitiesPipeline do subgroup_entity = BulkImports::Entity.last - expect(subgroup_entity.source_full_path).to eq 'parent/subgroup' + expect(subgroup_entity.source_full_path).to eq 'parent/sub-group' expect(subgroup_entity.destination_namespace).to eq 'imported-group' - expect(subgroup_entity.destination_name).to eq 'subgroup' + expect(subgroup_entity.destination_name).to eq 'sub-group' expect(subgroup_entity.parent_id).to eq parent_entity.id end end @@ -51,9 +51,7 @@ RSpec.describe BulkImports::Groups::Pipelines::SubgroupEntitiesPipeline do destination_namespace: parent_entity.group.full_path, parent_id: parent_entity.id } - expect { subject.load(context, data) }.to change(BulkImports::Entity, :count).by(1) - subgroup_entity = BulkImports::Entity.last expect(subgroup_entity.source_full_path).to eq 'parent/subgroup' diff --git a/spec/lib/bulk_imports/groups/transformers/group_attributes_transformer_spec.rb b/spec/lib/bulk_imports/groups/transformers/group_attributes_transformer_spec.rb index 75d8c15088a..c42ca9bef3b 100644 --- a/spec/lib/bulk_imports/groups/transformers/group_attributes_transformer_spec.rb +++ b/spec/lib/bulk_imports/groups/transformers/group_attributes_transformer_spec.rb @@ -6,7 +6,6 @@ RSpec.describe BulkImports::Groups::Transformers::GroupAttributesTransformer do describe '#transform' do let_it_be(:user) { create(:user) } let_it_be(:parent) { create(:group) } - let_it_be(:group) { create(:group, name: 'My Source Group', parent: parent) } let_it_be(:bulk_import) { create(:bulk_import, user: user) } let_it_be(:entity) do @@ -14,7 +13,7 @@ RSpec.describe BulkImports::Groups::Transformers::GroupAttributesTransformer do :bulk_import_entity, bulk_import: bulk_import, source_full_path: 'source/full/path', - destination_name: group.name, + destination_name: 'destination-name-path', destination_namespace: parent.full_path ) end @@ -24,7 +23,8 @@ RSpec.describe BulkImports::Groups::Transformers::GroupAttributesTransformer do let(:data) do { - 'name' => 'source_name', + 'name' => 'Source Group Name', + 'path' => 'source-group-path', 'full_path' => 'source/full/path', 'visibility' => 'private', 'project_creation_level' => 'developer', @@ -34,23 +34,27 @@ RSpec.describe BulkImports::Groups::Transformers::GroupAttributesTransformer do subject { described_class.new } - it 'transforms name to destination name' do - transformed_data = subject.transform(context, data) + it 'returns original data with some keys transformed' do + transformed_data = subject.transform(context, { 'name' => 'Name', 'description' => 'Description' }) - expect(transformed_data['name']).not_to eq('source_name') - expect(transformed_data['name']).to eq(group.name) + expect(transformed_data).to eq({ + 'name' => 'Name', + 'description' => 'Description', + 'parent_id' => parent.id, + 'path' => 'destination-name-path' + }) end - it 'removes full path' do + it 'transforms path from destination_name' do transformed_data = subject.transform(context, data) - expect(transformed_data).not_to have_key('full_path') + expect(transformed_data['path']).to eq(entity.destination_name) end - it 'transforms path to parameterized name' do + it 'removes full path' do transformed_data = subject.transform(context, data) - expect(transformed_data['path']).to eq(group.name.parameterize) + expect(transformed_data).not_to have_key('full_path') end it 'transforms visibility level' do diff --git a/spec/lib/bulk_imports/groups/transformers/subgroup_to_entity_transformer_spec.rb b/spec/lib/bulk_imports/groups/transformers/subgroup_to_entity_transformer_spec.rb index 2f97a5721e7..6450d90ec0f 100644 --- a/spec/lib/bulk_imports/groups/transformers/subgroup_to_entity_transformer_spec.rb +++ b/spec/lib/bulk_imports/groups/transformers/subgroup_to_entity_transformer_spec.rb @@ -9,14 +9,14 @@ RSpec.describe BulkImports::Groups::Transformers::SubgroupToEntityTransformer do parent_entity = instance_double(BulkImports::Entity, group: parent, id: 1) context = instance_double(BulkImports::Pipeline::Context, entity: parent_entity) subgroup_data = { - "name" => "subgroup", - "full_path" => "parent/subgroup" + "path" => "sub-group", + "full_path" => "parent/sub-group" } expect(subject.transform(context, subgroup_data)).to eq( source_type: :group_entity, - source_full_path: "parent/subgroup", - destination_name: "subgroup", + source_full_path: "parent/sub-group", + destination_name: "sub-group", destination_namespace: parent.full_path, parent_id: 1 ) |