diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /spec/models/group_group_link_spec.rb | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'spec/models/group_group_link_spec.rb')
-rw-r--r-- | spec/models/group_group_link_spec.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/models/group_group_link_spec.rb b/spec/models/group_group_link_spec.rb index 1fbd399e82b..54e622b2f22 100644 --- a/spec/models/group_group_link_spec.rb +++ b/spec/models/group_group_link_spec.rb @@ -29,6 +29,32 @@ describe GroupGroupLink do ]) end end + + describe '.public_or_visible_to_user' do + let!(:user_with_access) { create :user } + let!(:user_without_access) { create :user } + let!(:shared_with_group) { create :group, :private } + let!(:shared_group) { create :group } + let!(:private_group_group_link) { create(:group_group_link, shared_group: shared_group, shared_with_group: shared_with_group) } + + before do + shared_group.add_owner(user_with_access) + shared_group.add_owner(user_without_access) + shared_with_group.add_developer(user_with_access) + end + + context 'when user can access shared group' do + it 'returns the private group' do + expect(described_class.public_or_visible_to_user(shared_group, user_with_access)).to include(private_group_group_link) + end + end + + context 'when user does not have access to shared group' do + it 'does not return private group' do + expect(described_class.public_or_visible_to_user(shared_group, user_without_access)).not_to include(private_group_group_link) + end + end + end end describe 'validation' do |