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
9c50fa7c
Commit
9c50fa7c
authored
Jun 27, 2017
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create Group#users_with_descendants method
parent
3d5a4ce5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
0 deletions
+25
-0
app/models/group.rb
app/models/group.rb
+6
-0
spec/models/group_spec.rb
spec/models/group_spec.rb
+19
-0
No files found.
app/models/group.rb
View file @
9c50fa7c
...
@@ -266,6 +266,12 @@ class Group < Namespace
...
@@ -266,6 +266,12 @@ class Group < Namespace
User
.
where
(
id:
members_with_parents
.
select
(
:user_id
))
User
.
where
(
id:
members_with_parents
.
select
(
:user_id
))
end
end
def
users_with_descendants
members_with_descendants
=
GroupMember
.
non_request
.
where
(
source_id:
descendants
.
pluck
(
:id
).
push
(
id
))
User
.
where
(
id:
members_with_descendants
.
select
(
:user_id
))
end
def
max_member_access_for_user
(
user
)
def
max_member_access_for_user
(
user
)
return
GroupMember
::
OWNER
if
user
.
admin?
return
GroupMember
::
OWNER
if
user
.
admin?
...
...
spec/models/group_spec.rb
View file @
9c50fa7c
...
@@ -385,6 +385,25 @@ describe Group, models: true do
...
@@ -385,6 +385,25 @@ describe Group, models: true do
end
end
end
end
describe
'#users_with_descendants'
,
:nested_groups
do
let
(
:user_a
)
{
create
(
:user
)
}
let
(
:user_b
)
{
create
(
:user
)
}
let
(
:group
)
{
create
(
:group
)
}
let
(
:nested_group
)
{
create
(
:group
,
parent:
group
)
}
let
(
:deep_nested_group
)
{
create
(
:group
,
parent:
nested_group
)
}
it
'returns member users on every nest level without duplication'
do
group
.
add_developer
(
user_a
)
nested_group
.
add_developer
(
user_b
)
deep_nested_group
.
add_developer
(
user_a
)
expect
(
group
.
users_with_descendants
).
to
contain_exactly
(
user_a
,
user_b
)
expect
(
nested_group
.
users_with_descendants
).
to
contain_exactly
(
user_a
,
user_b
)
expect
(
deep_nested_group
.
users_with_descendants
).
to
contain_exactly
(
user_a
)
end
end
describe
'#user_ids_for_project_authorizations'
do
describe
'#user_ids_for_project_authorizations'
do
it
'returns the user IDs for which to refresh authorizations'
do
it
'returns the user IDs for which to refresh authorizations'
do
master
=
create
(
:user
)
master
=
create
(
:user
)
...
...
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