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
70dac459
Commit
70dac459
authored
Apr 02, 2020
by
Aakriti Gupta
Committed by
Bob Van Landuyt
Apr 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass params on initializing GroupMemberFinder
parent
fcf2ee20
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
14 deletions
+17
-14
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
+6
-3
ee/lib/analytics/group_activity_calculator.rb
ee/lib/analytics/group_activity_calculator.rb
+5
-5
spec/finders/group_members_finder_spec.rb
spec/finders/group_members_finder_spec.rb
+5
-5
No files found.
app/controllers/groups/group_members_controller.rb
View file @
70dac459
...
...
@@ -57,7 +57,7 @@ class Groups::GroupMembersController < Groups::ApplicationController
def
find_members
filter_params
=
params
.
slice
(
:two_factor
,
:search
).
merge
(
sort:
@sort
)
GroupMembersFinder
.
new
(
@group
,
current_user
).
execute
(
include_relations:
requested_relations
,
params:
filter_param
s
)
GroupMembersFinder
.
new
(
@group
,
current_user
,
params:
filter_params
).
execute
(
include_relations:
requested_relation
s
)
end
def
can_manage_members
...
...
app/finders/group_members_finder.rb
View file @
70dac459
...
...
@@ -10,13 +10,16 @@ class GroupMembersFinder < UnionFinder
# created_after: datetime
# created_before: datetime
def
initialize
(
group
,
user
=
nil
)
attr_reader
:params
def
initialize
(
group
,
user
=
nil
,
params:
{})
@group
=
group
@user
=
user
@params
=
params
end
# rubocop: disable CodeReuse/ActiveRecord
def
execute
(
include_relations:
[
:inherited
,
:direct
]
,
params:
{}
)
def
execute
(
include_relations:
[
:inherited
,
:direct
])
group_members
=
group
.
members
relations
=
[]
@params
=
params
...
...
@@ -50,7 +53,7 @@ class GroupMembersFinder < UnionFinder
private
attr_reader
:user
,
:group
,
:params
attr_reader
:user
,
:group
def
filter_members
(
members
)
members
=
members
.
search
(
params
[
:search
])
if
params
[
:search
].
present?
...
...
ee/lib/analytics/group_activity_calculator.rb
View file @
70dac459
...
...
@@ -21,11 +21,11 @@ module Analytics
def
new_members_count
@new_members_count
||=
GroupMembersFinder
.
new
(
@group
,
@current_user
)
.
execute
(
include_relations:
[
:direct
,
:descendants
]
,
GroupMembersFinder
.
new
(
@group
,
@current_user
,
params:
{
created_after:
DURATION
.
ago
}
).
count
).
execute
(
include_relations:
[
:direct
,
:descendants
]
).
count
end
private
...
...
spec/finders/group_members_finder_spec.rb
View file @
70dac459
...
...
@@ -82,7 +82,7 @@ describe GroupMembersFinder, '#execute' do
group
.
add_developer
(
user3
)
member
=
group
.
add_maintainer
(
user1
)
result
=
described_class
.
new
(
group
).
execute
(
params:
{
search:
user1
.
name
})
result
=
described_class
.
new
(
group
,
params:
{
search:
user1
.
name
}).
execute
expect
(
result
.
to_a
).
to
match_array
([
member
])
end
...
...
@@ -92,7 +92,7 @@ describe GroupMembersFinder, '#execute' do
group
.
add_developer
(
user3
)
group
.
add_maintainer
(
user1
)
result
=
described_class
.
new
(
group
).
execute
(
include_relations:
[
:inherited
],
params:
{
search:
user1
.
name
}
)
result
=
described_class
.
new
(
group
,
params:
{
search:
user1
.
name
}).
execute
(
include_relations:
[
:inherited
]
)
expect
(
result
.
to_a
).
to
match_array
([])
end
...
...
@@ -103,7 +103,7 @@ describe GroupMembersFinder, '#execute' do
nested_group
.
add_maintainer
(
create
(
:user
,
name:
user1
.
name
))
member
=
group
.
add_maintainer
(
user1
)
result
=
described_class
.
new
(
nested_group
).
execute
(
include_relations:
[
:inherited
],
params:
{
search:
member
.
user
.
name
}
)
result
=
described_class
.
new
(
nested_group
,
params:
{
search:
member
.
user
.
name
}).
execute
(
include_relations:
[
:inherited
]
)
expect
(
result
.
to_a
).
to
contain_exactly
(
member
)
end
...
...
@@ -113,7 +113,7 @@ describe GroupMembersFinder, '#execute' do
group
.
add_maintainer
(
user1
)
member
=
group
.
add_maintainer
(
user5
)
result
=
described_class
.
new
(
group
,
user2
).
execute
(
params:
{
two_factor:
'enabled'
})
result
=
described_class
.
new
(
group
,
user2
,
params:
{
two_factor:
'enabled'
}).
execute
expect
(
result
.
to_a
).
to
contain_exactly
(
member
)
end
...
...
@@ -123,7 +123,7 @@ describe GroupMembersFinder, '#execute' do
member2
=
group
.
add_maintainer
(
user1
)
member_with_2fa
=
group
.
add_maintainer
(
user5
)
result
=
described_class
.
new
(
group
,
user2
).
execute
(
params:
{
two_factor:
'disabled'
})
result
=
described_class
.
new
(
group
,
user2
,
params:
{
two_factor:
'disabled'
}).
execute
expect
(
result
.
to_a
).
not_to
include
(
member_with_2fa
)
expect
(
result
.
to_a
).
to
match_array
([
member1
,
member2
])
...
...
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