diff options
Diffstat (limited to 'spec/finders/groups_finder_spec.rb')
-rw-r--r-- | spec/finders/groups_finder_spec.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/finders/groups_finder_spec.rb b/spec/finders/groups_finder_spec.rb index f20c03c9658..5d69988a761 100644 --- a/spec/finders/groups_finder_spec.rb +++ b/spec/finders/groups_finder_spec.rb @@ -274,6 +274,38 @@ RSpec.describe GroupsFinder, feature_category: :groups_and_projects do end end + context 'with organization' do + let_it_be(:organization_user) { create(:organization_user) } + let_it_be(:organization) { organization_user.organization } + let_it_be(:user) { organization_user.user } + let_it_be(:public_group) { create(:group, name: 'public-group', organization: organization) } + let_it_be(:outside_organization_group) { create(:group) } + let_it_be(:private_group) { create(:group, :private, name: 'private-group', organization: organization) } + let_it_be(:no_access_group_in_org) { create(:group, :private, name: 'no-access', organization: organization) } + + let(:current_user) { user } + let(:params) { { organization: organization } } + let(:finder) { described_class.new(current_user, params) } + + subject(:result) { finder.execute.to_a } + + before_all do + private_group.add_developer(user) + public_group.add_developer(user) + outside_organization_group.add_developer(user) + end + + context 'when user is only authorized to read the public group' do + let(:current_user) { create(:user) } + + it { is_expected.to contain_exactly(public_group) } + end + + it 'return all groups inside the organization' do + expect(result).to contain_exactly(public_group, private_group) + end + end + context 'with include_ancestors' do let_it_be(:user) { create(:user) } |