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
d568481f
Commit
d568481f
authored
Aug 24, 2021
by
Francisco Javier López
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use linear version User#groups_with_developer_maintainer_project_access
Changelog: performance
parent
fe5831c6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
3 deletions
+59
-3
app/models/user.rb
app/models/user.rb
+6
-3
config/feature_flags/development/linear_user_groups_with_developer_maintainer_project_access.yml
..._user_groups_with_developer_maintainer_project_access.yml
+8
-0
spec/models/user_spec.rb
spec/models/user_spec.rb
+45
-0
No files found.
app/models/user.rb
View file @
d568481f
...
@@ -2117,9 +2117,12 @@ class User < ApplicationRecord
...
@@ -2117,9 +2117,12 @@ class User < ApplicationRecord
project_creation_levels
<<
nil
project_creation_levels
<<
nil
end
end
if
Feature
.
enabled?
(
:linear_user_groups_with_developer_maintainer_project_access
,
self
,
default_enabled: :yaml
)
developer_groups
.
self_and_descendants
.
where
(
project_creation_level:
project_creation_levels
)
else
developer_groups_hierarchy
=
::
Gitlab
::
ObjectHierarchy
.
new
(
developer_groups
).
base_and_descendants
developer_groups_hierarchy
=
::
Gitlab
::
ObjectHierarchy
.
new
(
developer_groups
).
base_and_descendants
::
Group
.
where
(
id:
developer_groups_hierarchy
.
select
(
:id
),
::
Group
.
where
(
id:
developer_groups_hierarchy
.
select
(
:id
),
project_creation_level:
project_creation_levels
)
project_creation_level:
project_creation_levels
)
end
end
end
def
no_recent_activity?
def
no_recent_activity?
...
...
config/feature_flags/development/linear_user_groups_with_developer_maintainer_project_access.yml
0 → 100644
View file @
d568481f
---
name
:
linear_user_groups_with_developer_maintainer_project_access
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/68851
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/339436
milestone
:
'
14.3'
type
:
development
group
:
group::access
default_enabled
:
false
spec/models/user_spec.rb
View file @
d568481f
...
@@ -5999,4 +5999,49 @@ RSpec.describe User do
...
@@ -5999,4 +5999,49 @@ RSpec.describe User do
end
end
end
end
end
end
describe
'#groups_with_developer_maintainer_project_access'
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:group1
)
{
create
(
:group
)
}
let_it_be
(
:developer_group1
)
do
create
(
:group
).
tap
do
|
g
|
g
.
add_developer
(
user
)
end
end
let_it_be
(
:developer_group2
)
do
create
(
:group
,
project_creation_level:
::
Gitlab
::
Access
::
DEVELOPER_MAINTAINER_PROJECT_ACCESS
).
tap
do
|
g
|
g
.
add_developer
(
user
)
end
end
let_it_be
(
:guest_group1
)
do
create
(
:group
,
project_creation_level:
::
Gitlab
::
Access
::
DEVELOPER_MAINTAINER_PROJECT_ACCESS
).
tap
do
|
g
|
g
.
add_guest
(
user
)
end
end
let_it_be
(
:developer_group1
)
do
create
(
:group
,
project_creation_level:
::
Gitlab
::
Access
::
DEVELOPER_MAINTAINER_PROJECT_ACCESS
).
tap
do
|
g
|
g
.
add_maintainer
(
user
)
end
end
subject
{
user
.
send
(
:groups_with_developer_maintainer_project_access
)
}
shared_examples
'groups_with_developer_maintainer_project_access examples'
do
specify
{
is_expected
.
to
contain_exactly
(
developer_group2
)
}
end
it_behaves_like
'groups_with_developer_maintainer_project_access examples'
context
'when feature flag :linear_user_groups_with_developer_maintainer_project_access is disabled'
do
before
do
stub_feature_flags
(
linear_user_groups_with_developer_maintainer_project_access:
false
)
end
it_behaves_like
'groups_with_developer_maintainer_project_access examples'
end
end
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