diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
commit | 3cccd102ba543e02725d247893729e5c73b38295 (patch) | |
tree | f36a04ec38517f5deaaacb5acc7d949688d1e187 /spec/helpers/groups/group_members_helper_spec.rb | |
parent | 205943281328046ef7b4528031b90fbda70c75ac (diff) |
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'spec/helpers/groups/group_members_helper_spec.rb')
-rw-r--r-- | spec/helpers/groups/group_members_helper_spec.rb | 62 |
1 files changed, 61 insertions, 1 deletions
diff --git a/spec/helpers/groups/group_members_helper_spec.rb b/spec/helpers/groups/group_members_helper_spec.rb index f5bc587bce3..ab11bc1f5fd 100644 --- a/spec/helpers/groups/group_members_helper_spec.rb +++ b/spec/helpers/groups/group_members_helper_spec.rb @@ -38,7 +38,9 @@ RSpec.describe Groups::GroupMembersHelper do shared_group, members: present_members(members_collection), invited: present_members(invited), - access_requests: present_members(access_requests) + access_requests: present_members(access_requests), + include_relations: [:inherited, :direct], + search: nil ) end @@ -96,6 +98,64 @@ RSpec.describe Groups::GroupMembersHelper do it 'sets `member_path` property' do expect(subject[:group][:member_path]).to eq('/groups/foo-bar/-/group_links/:id') end + + context 'inherited' do + let_it_be(:sub_shared_group) { create(:group, parent: shared_group) } + let_it_be(:sub_shared_with_group) { create(:group) } + let_it_be(:sub_group_group_link) { create(:group_group_link, shared_group: sub_shared_group, shared_with_group: sub_shared_with_group) } + + let_it_be(:subject_group) { sub_shared_group } + + before do + allow(helper).to receive(:group_group_member_path).with(sub_shared_group, ':id').and_return('/groups/foo-bar/-/group_members/:id') + allow(helper).to receive(:group_group_link_path).with(sub_shared_group, ':id').and_return('/groups/foo-bar/-/group_links/:id') + allow(helper).to receive(:can?).with(current_user, :admin_group_member, sub_shared_group).and_return(true) + allow(helper).to receive(:can?).with(current_user, :export_group_memberships, sub_shared_group).and_return(true) + end + + subject do + helper.group_members_app_data( + sub_shared_group, + members: present_members(members_collection), + invited: present_members(invited), + access_requests: present_members(access_requests), + include_relations: include_relations, + search: nil + ) + end + + using RSpec::Parameterized::TableSyntax + + where(:include_relations, :result) do + [:inherited, :direct] | lazy { [group_group_link, sub_group_group_link].map(&:id) } + [:inherited] | lazy { [group_group_link].map(&:id) } + [:direct] | lazy { [sub_group_group_link].map(&:id) } + end + + with_them do + it 'returns correct group links' do + expect(subject[:group][:members].map { |link| link[:id] }).to match_array(result) + end + end + + context 'when group_member_inherited_group disabled' do + before do + stub_feature_flags(group_member_inherited_group: false) + end + + where(:include_relations, :result) do + [:inherited, :direct] | lazy { [sub_group_group_link.id] } + [:inherited] | lazy { [sub_group_group_link.id] } + [:direct] | lazy { [sub_group_group_link.id] } + end + + with_them do + it 'always returns direct member links' do + expect(subject[:group][:members].map { |link| link[:id] }).to match_array(result) + end + end + end + end end context 'when pagination is not available' do |