Commit 2daee112 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'georgekoltsov/fix-group-export-descendants' into 'master'

Fix sub group export to export direct children

See merge request gitlab-org/gitlab!20172
parents d357c692 f46a77a6
---
title: Fix sub group export to export direct children
merge_request: 20172
author:
type: fixed
......@@ -28,9 +28,9 @@ module Gitlab
def serialize(group, relations_tree)
group_tree = tree_saver.serialize(group, relations_tree)
group.descendants.each do |descendant|
group_tree['descendants'] = [] unless group_tree['descendants']
group_tree['descendants'] << serialize(descendant, relations_tree)
group.children.each do |child|
group_tree['children'] ||= []
group_tree['children'] << serialize(child, relations_tree)
end
group_tree
......
......@@ -39,12 +39,16 @@ describe Gitlab::ImportExport::GroupTreeSaver do
end
context 'when :export_fast_serialize feature is enabled' do
let(:serializer) { instance_double(Gitlab::ImportExport::FastHashSerializer) }
before do
stub_feature_flags(export_fast_serialize: true)
expect(Gitlab::ImportExport::FastHashSerializer).to receive(:new).with(group, group_tree).and_return(serializer)
end
it 'uses FastHashSerializer' do
expect_any_instance_of(Gitlab::ImportExport::FastHashSerializer).to receive(:execute).and_call_original
expect(serializer).to receive(:execute)
group_tree_saver.save
end
......@@ -103,6 +107,18 @@ describe Gitlab::ImportExport::GroupTreeSaver do
expect(saved_group_json['badges']).not_to be_empty
end
context 'group children' do
let(:children) { group.children }
it 'exports group children' do
expect(saved_group_json['children'].length).to eq(children.count)
end
it 'exports group children of children' do
expect(saved_group_json['children'].first['children'].length).to eq(children.first.children.count)
end
end
context 'group members' do
let(:user2) { create(:user, email: 'group@member.com') }
let(:member_emails) do
......@@ -146,6 +162,8 @@ describe Gitlab::ImportExport::GroupTreeSaver do
def setup_group
group = create(:group, description: 'description')
sub_group = create(:group, description: 'description', parent: group)
create(:group, description: 'description', parent: sub_group)
create(:milestone, group: group)
create(:group_badge, group: group)
group_label = create(:group_label, group: group)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment