Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-12-15 18:13:59 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-12-15 18:13:59 +0300
commitf9da8786f9421281e390d921333f8ff4c9941354 (patch)
tree88e44000c2abe0589cf3aee22861eb7a73146127 /spec/finders
parenta19ad7fa983054d09b35c5fe0bdf853acc55a1bc (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/finders')
-rw-r--r--spec/finders/groups_finder_spec.rb32
-rw-r--r--spec/finders/organizations/groups_finder_spec.rb84
2 files changed, 32 insertions, 84 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) }
diff --git a/spec/finders/organizations/groups_finder_spec.rb b/spec/finders/organizations/groups_finder_spec.rb
deleted file mode 100644
index 08c5604149b..00000000000
--- a/spec/finders/organizations/groups_finder_spec.rb
+++ /dev/null
@@ -1,84 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe Organizations::GroupsFinder, feature_category: :cell 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(:other_group) { create(:group, name: 'other-group', organization: organization) }
- let_it_be(:outside_organization_group) { create(:group) }
- let_it_be(:private_group) do
- create(:group, :private, name: 'private-group', organization: organization)
- end
-
- let_it_be(:no_access_group_in_org) do
- create(:group, :private, name: 'no-access', organization: organization)
- end
-
- let(:current_user) { user }
- let(:params) { {} }
- let(:finder) { described_class.new(organization: organization, current_user: current_user, params: params) }
-
- before_all do
- private_group.add_developer(user)
- public_group.add_developer(user)
- other_group.add_developer(user)
- outside_organization_group.add_developer(user)
- end
-
- subject(:result) { finder.execute.to_a }
-
- describe '#execute' do
- context 'when user is not authorized to read the organization' do
- let(:current_user) { create(:user) }
-
- it { is_expected.to be_empty }
- end
-
- context 'when organization is nil' do
- let(:organization) { nil }
-
- it { is_expected.to be_empty }
- end
-
- context 'when user is authorized to read the organization' do
- it 'return all accessible groups' do
- expect(result).to contain_exactly(public_group, private_group, other_group)
- end
-
- context 'when search param is passed' do
- let(:params) { { search: 'the' } }
-
- it 'filters the groups by search' do
- expect(result).to contain_exactly(other_group)
- end
- end
-
- context 'when sort param is not passed' do
- it 'return groups sorted by name in ascending order by default' do
- expect(result).to eq([other_group, private_group, public_group])
- end
- end
-
- context 'when sort param is passed' do
- using RSpec::Parameterized::TableSyntax
-
- where(:field, :direction, :sorted_groups) do
- 'name' | 'asc' | lazy { [other_group, private_group, public_group] }
- 'name' | 'desc' | lazy { [public_group, private_group, other_group] }
- 'path' | 'asc' | lazy { [other_group, private_group, public_group] }
- 'path' | 'desc' | lazy { [public_group, private_group, other_group] }
- end
-
- with_them do
- let(:params) { { sort: { field: field, direction: direction } } }
- it 'sorts the groups' do
- expect(result).to eq(sorted_groups)
- end
- end
- end
- end
- end
-end