Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
f9818cfe
Commit
f9818cfe
authored
Aug 24, 2021
by
Francisco Javier López
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use linear version of User#manageable_groups
Changelog: performance
parent
220728f1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
6 deletions
+30
-6
app/models/user.rb
app/models/user.rb
+5
-1
config/feature_flags/development/linear_user_manageable_groups.yml
...ature_flags/development/linear_user_manageable_groups.yml
+8
-0
spec/models/user_spec.rb
spec/models/user_spec.rb
+17
-5
No files found.
app/models/user.rb
View file @
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
(
...
...
config/feature_flags/development/linear_user_manageable_groups.yml
0 → 100644
View file @
f9818cfe
---
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
spec/models/user_spec.rb
View file @
f9818cfe
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment