diff options
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 |