diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-09-07 19:08:56 +0200 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-10-04 22:49:41 +0200 |
commit | 518216c0627cb6c4b3db62f10877b44d0e912ddb (patch) | |
tree | 68a4aa0a3301728097e73c6e09c48780a1b52757 /spec/serializers | |
parent | 530cf2a2669ea1ee3c41d48a15919f875babefa4 (diff) | |
download | gitlab-ce-518216c0627cb6c4b3db62f10877b44d0e912ddb.tar.gz |
Merge group hierarchies when parents are shared
Diffstat (limited to 'spec/serializers')
-rw-r--r-- | spec/serializers/group_child_serializer_spec.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/serializers/group_child_serializer_spec.rb b/spec/serializers/group_child_serializer_spec.rb new file mode 100644 index 00000000000..967ed06d316 --- /dev/null +++ b/spec/serializers/group_child_serializer_spec.rb @@ -0,0 +1,43 @@ +require 'spec_helper' + +describe GroupChildSerializer do + let(:request) { double('request') } + let(:user) { create(:user) } + subject(:serializer) { described_class.new(current_user: user) } + + describe '#represent' do + context 'for groups' do + it 'can render a single group' do + expect(serializer.represent(build(:group))).to be_kind_of(Hash) + end + + it 'can render a collection of groups' do + expect(serializer.represent(build_list(:group, 2))).to be_kind_of(Array) + end + end + + context 'with a hierarchy' do + let(:parent) { create(:group) } + + subject(:serializer) do + described_class.new(current_user: user).expand_hierarchy(parent) + end + + it 'expands the subgroups' do + subgroup = create(:group, parent: parent) + subsub_group = create(:group, parent: subgroup) + + json = serializer.represent(subsub_group) + subsub_group_json = json[:children].first + + expect(json[:id]).to eq(subgroup.id) + expect(subsub_group_json).not_to be_nil + expect(subsub_group_json[:id]).to eq(subsub_group.id) + end + + it 'can expand multiple trees' do + + end + end + end +end |