Commit 57cc0fda authored by Sean McGivern's avatar Sean McGivern

Merge branch '339197-fj-linear-manageable-groups' into 'master'

Use linear version of User#manageable_groups

See merge request gitlab-org/gitlab!68845
parents 52828e6a f9818cfe
......@@ -1550,7 +1550,11 @@ class User < ApplicationRecord
end
def manageable_groups(include_groups_with_developer_maintainer_access: false)
owned_and_maintainer_group_hierarchy = Gitlab::ObjectHierarchy.new(owned_or_maintainers_groups).base_and_descendants
owned_and_maintainer_group_hierarchy = if Feature.enabled?(:linear_user_manageable_groups, self, default_enabled: :yaml)
owned_or_maintainers_groups.self_and_descendants
else
Gitlab::ObjectHierarchy.new(owned_or_maintainers_groups).base_and_descendants
end
if include_groups_with_developer_maintainer_access
union_sql = ::Gitlab::SQL::Union.new(
......
---
name: linear_user_manageable_groups
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/68845
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/339434
milestone: '14.3'
type: development
group: group::access
default_enabled: false
......@@ -1755,14 +1755,26 @@ RSpec.describe User do
end
describe '#manageable_groups' do
it 'includes all the namespaces the user can manage' do
expect(user.manageable_groups).to contain_exactly(group, subgroup)
shared_examples 'manageable groups examples' do
it 'includes all the namespaces the user can manage' do
expect(user.manageable_groups).to contain_exactly(group, subgroup)
end
it 'does not include duplicates if a membership was added for the subgroup' do
subgroup.add_owner(user)
expect(user.manageable_groups).to contain_exactly(group, subgroup)
end
end
it 'does not include duplicates if a membership was added for the subgroup' do
subgroup.add_owner(user)
it_behaves_like 'manageable groups examples'
context 'when feature flag :linear_user_manageable_groups is disabled' do
before do
stub_feature_flags(linear_user_manageable_groups: false)
end
expect(user.manageable_groups).to contain_exactly(group, subgroup)
it_behaves_like 'manageable groups examples'
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment