diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
commit | 36a59d088eca61b834191dacea009677a96c052f (patch) | |
tree | e4f33972dab5d8ef79e3944a9f403035fceea43f /spec/lib/bulk_imports/groups/transformers | |
parent | a1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff) |
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
Diffstat (limited to 'spec/lib/bulk_imports/groups/transformers')
-rw-r--r-- | spec/lib/bulk_imports/groups/transformers/group_attributes_transformer_spec.rb | 26 | ||||
-rw-r--r-- | spec/lib/bulk_imports/groups/transformers/subgroup_to_entity_transformer_spec.rb | 8 |
2 files changed, 19 insertions, 15 deletions
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 ) |