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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
5f85487c
Commit
5f85487c
authored
Feb 08, 2017
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show parent group members for nested group
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
059d1ae4
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
107 additions
and
5 deletions
+107
-5
app/controllers/groups/group_members_controller.rb
app/controllers/groups/group_members_controller.rb
+1
-1
app/finders/group_members_finder.rb
app/finders/group_members_finder.rb
+20
-0
app/models/group.rb
app/models/group.rb
+1
-1
app/models/member.rb
app/models/member.rb
+1
-0
app/views/shared/members/_member.html.haml
app/views/shared/members/_member.html.haml
+4
-3
spec/features/groups/members/list_spec.rb
spec/features/groups/members/list_spec.rb
+40
-0
spec/finders/group_members_finder_spec.rb
spec/finders/group_members_finder_spec.rb
+32
-0
spec/models/member_spec.rb
spec/models/member_spec.rb
+8
-0
No files found.
app/controllers/groups/group_members_controller.rb
View file @
5f85487c
...
@@ -9,7 +9,7 @@ class Groups::GroupMembersController < Groups::ApplicationController
...
@@ -9,7 +9,7 @@ class Groups::GroupMembersController < Groups::ApplicationController
@sort
=
params
[
:sort
].
presence
||
sort_value_name
@sort
=
params
[
:sort
].
presence
||
sort_value_name
@project
=
@group
.
projects
.
find
(
params
[
:project_id
])
if
params
[
:project_id
]
@project
=
@group
.
projects
.
find
(
params
[
:project_id
])
if
params
[
:project_id
]
@members
=
@group
.
group_members
@members
=
GroupMembersFinder
.
new
(
@group
).
execute
@members
=
@members
.
non_invite
unless
can?
(
current_user
,
:admin_group
,
@group
)
@members
=
@members
.
non_invite
unless
can?
(
current_user
,
:admin_group
,
@group
)
@members
=
@members
.
search
(
params
[
:search
])
if
params
[
:search
].
present?
@members
=
@members
.
search
(
params
[
:search
])
if
params
[
:search
].
present?
@members
=
@members
.
sort
(
@sort
)
@members
=
@members
.
sort
(
@sort
)
...
...
app/finders/group_members_finder.rb
0 → 100644
View file @
5f85487c
class
GroupMembersFinder
<
Projects
::
ApplicationController
def
initialize
(
group
)
@group
=
group
end
def
execute
group_members
=
@group
.
members
return
group_members
unless
@group
.
parent
parents_members
=
GroupMember
.
non_request
.
where
(
source_id:
@group
.
ancestors
.
select
(
:id
)).
where
.
not
(
user_id:
@group
.
users
.
select
(
:id
))
wheres
=
[
"members.id IN (
#{
group_members
.
select
(
:id
).
to_sql
}
)"
]
wheres
<<
"members.id IN (
#{
parents_members
.
select
(
:id
).
to_sql
}
)"
GroupMember
.
where
(
wheres
.
join
(
' OR '
))
end
end
app/models/group.rb
View file @
5f85487c
...
@@ -206,7 +206,7 @@ class Group < Namespace
...
@@ -206,7 +206,7 @@ class Group < Namespace
end
end
def
members_with_parents
def
members_with_parents
GroupMember
.
where
(
requested_at:
nil
,
source_id:
ancestors
.
map
(
&
:id
).
push
(
id
))
GroupMember
.
non_request
.
where
(
source_id:
ancestors
.
map
(
&
:id
).
push
(
id
))
end
end
def
users_with_parents
def
users_with_parents
...
...
app/models/member.rb
View file @
5f85487c
...
@@ -47,6 +47,7 @@ class Member < ActiveRecord::Base
...
@@ -47,6 +47,7 @@ class Member < ActiveRecord::Base
scope
:invite
,
->
{
where
.
not
(
invite_token:
nil
)
}
scope
:invite
,
->
{
where
.
not
(
invite_token:
nil
)
}
scope
:non_invite
,
->
{
where
(
invite_token:
nil
)
}
scope
:non_invite
,
->
{
where
(
invite_token:
nil
)
}
scope
:request
,
->
{
where
.
not
(
requested_at:
nil
)
}
scope
:request
,
->
{
where
.
not
(
requested_at:
nil
)
}
scope
:non_request
,
->
{
where
(
requested_at:
nil
)
}
scope
:has_access
,
->
{
active
.
where
(
'access_level > 0'
)
}
scope
:has_access
,
->
{
active
.
where
(
'access_level > 0'
)
}
...
...
app/views/shared/members/_member.html.haml
View file @
5f85487c
...
@@ -19,9 +19,9 @@
...
@@ -19,9 +19,9 @@
%label
.label.label-danger
%label
.label.label-danger
%strong
Blocked
%strong
Blocked
-
if
source
.
instance_of?
(
Group
)
&&
!
@group
-
if
source
.
instance_of?
(
Group
)
&&
source
!=
@group
·
·
=
link_to
source
.
name
,
source
,
class:
"member-group-link"
=
link_to
source
.
full_
name
,
source
,
class:
"member-group-link"
.hidden-xs.cgray
.hidden-xs.cgray
-
if
member
.
request?
-
if
member
.
request?
...
@@ -44,8 +44,9 @@
...
@@ -44,8 +44,9 @@
=
link_to
member
.
created_by
.
name
,
user_path
(
member
.
created_by
)
=
link_to
member
.
created_by
.
name
,
user_path
(
member
.
created_by
)
=
time_ago_with_tooltip
(
member
.
created_at
)
=
time_ago_with_tooltip
(
member
.
created_at
)
-
if
show_roles
-
if
show_roles
-
current_resource
=
@project
||
@group
.controls.member-controls
.controls.member-controls
-
if
show_controls
&&
(
member
.
respond_to?
(
:group
)
&&
@group
)
||
(
member
.
respond_to?
(
:project
)
&&
@project
)
-
if
show_controls
&&
member
.
source
==
current_resource
-
if
user
!=
current_user
-
if
user
!=
current_user
=
form_for
member
,
remote:
true
,
html:
{
class:
'form-horizontal js-edit-member-form'
}
do
|
f
|
=
form_for
member
,
remote:
true
,
html:
{
class:
'form-horizontal js-edit-member-form'
}
do
|
f
|
=
f
.
hidden_field
:access_level
=
f
.
hidden_field
:access_level
...
...
spec/features/groups/members/list_spec.rb
0 → 100644
View file @
5f85487c
require
'spec_helper'
feature
'Groups members list'
,
feature:
true
do
let
(
:user1
)
{
create
(
:user
,
name:
'John Doe'
)
}
let
(
:user2
)
{
create
(
:user
,
name:
'Mary Jane'
)
}
let
(
:group
)
{
create
(
:group
)
}
let
(
:nested_group
)
{
create
(
:group
,
parent:
group
)
}
background
do
login_as
(
user1
)
end
scenario
'show members from current group and parent'
do
group
.
add_developer
(
user1
)
nested_group
.
add_developer
(
user2
)
visit
group_group_members_path
(
nested_group
)
expect
(
first_row
.
text
).
to
include
(
user1
.
name
)
expect
(
second_row
.
text
).
to
include
(
user2
.
name
)
end
scenario
'show user once if member of both current group and parent'
do
group
.
add_developer
(
user1
)
nested_group
.
add_developer
(
user1
)
visit
group_group_members_path
(
nested_group
)
expect
(
first_row
.
text
).
to
include
(
user1
.
name
)
expect
(
second_row
).
to
be_blank
end
def
first_row
page
.
all
(
'ul.content-list > li'
)[
0
]
end
def
second_row
page
.
all
(
'ul.content-list > li'
)[
1
]
end
end
spec/finders/group_members_finder_spec.rb
0 → 100644
View file @
5f85487c
require
'spec_helper'
describe
GroupMembersFinder
,
'#execute'
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:nested_group
)
{
create
(
:group
,
:access_requestable
,
parent:
group
)
}
let
(
:user1
)
{
create
(
:user
)
}
let
(
:user2
)
{
create
(
:user
)
}
let
(
:user3
)
{
create
(
:user
)
}
let
(
:user4
)
{
create
(
:user
)
}
it
'returns members for top-level group'
do
member1
=
group
.
add_master
(
user1
)
member2
=
group
.
add_master
(
user2
)
member3
=
group
.
add_master
(
user3
)
result
=
described_class
.
new
(
group
).
execute
expect
(
result
.
to_a
).
to
eq
([
member3
,
member2
,
member1
])
end
it
'returns members for nested group'
do
group
.
add_master
(
user2
)
nested_group
.
request_access
(
user4
)
member1
=
group
.
add_master
(
user1
)
member3
=
nested_group
.
add_master
(
user2
)
member4
=
nested_group
.
add_master
(
user3
)
result
=
described_class
.
new
(
nested_group
).
execute
expect
(
result
.
to_a
).
to
eq
([
member4
,
member3
,
member1
])
end
end
spec/models/member_spec.rb
View file @
5f85487c
...
@@ -129,6 +129,14 @@ describe Member, models: true do
...
@@ -129,6 +129,14 @@ describe Member, models: true do
it
{
expect
(
described_class
.
request
).
not_to
include
@accepted_request_member
}
it
{
expect
(
described_class
.
request
).
not_to
include
@accepted_request_member
}
end
end
describe
'.non_request'
do
it
{
expect
(
described_class
.
non_request
).
to
include
@master
}
it
{
expect
(
described_class
.
non_request
).
to
include
@invited_member
}
it
{
expect
(
described_class
.
non_request
).
to
include
@accepted_invite_member
}
it
{
expect
(
described_class
.
non_request
).
not_to
include
@requested_member
}
it
{
expect
(
described_class
.
non_request
).
to
include
@accepted_request_member
}
end
describe
'.developers'
do
describe
'.developers'
do
subject
{
described_class
.
developers
.
to_a
}
subject
{
described_class
.
developers
.
to_a
}
...
...
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