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
b86308df
Commit
b86308df
authored
Jan 16, 2020
by
Gosia Ksionek
Committed by
Imre Farkas
Jan 16, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "NoMethodError: undefined method `sort_by_attribute' for nil:NilClass"
parent
76ff8a57
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
13 deletions
+42
-13
app/finders/group_members_finder.rb
app/finders/group_members_finder.rb
+2
-0
changelogs/unreleased/197143-nomethoderror-undefined-method-sort_by_attribute-for-nil-nilclass.yml
...r-undefined-method-sort_by_attribute-for-nil-nilclass.yml
+6
-0
spec/finders/group_members_finder_spec.rb
spec/finders/group_members_finder_spec.rb
+34
-13
No files found.
app/finders/group_members_finder.rb
View file @
b86308df
...
@@ -36,6 +36,8 @@ class GroupMembersFinder < UnionFinder
...
@@ -36,6 +36,8 @@ class GroupMembersFinder < UnionFinder
relations
<<
descendant_members
relations
<<
descendant_members
end
end
return
GroupMember
.
none
if
relations
.
empty?
members
=
find_union
(
relations
,
GroupMember
)
members
=
find_union
(
relations
,
GroupMember
)
filter_members
(
members
,
params
)
filter_members
(
members
,
params
)
end
end
...
...
changelogs/unreleased/197143-nomethoderror-undefined-method-sort_by_attribute-for-nil-nilclass.yml
0 → 100644
View file @
b86308df
---
title
:
Add returning relation from GroupMembersFinder if called on root group with
only inherited param
merge_request
:
23161
author
:
type
:
fixed
spec/finders/group_members_finder_spec.rb
View file @
b86308df
...
@@ -57,6 +57,14 @@ describe GroupMembersFinder, '#execute' do
...
@@ -57,6 +57,14 @@ describe GroupMembersFinder, '#execute' do
expect
(
result
.
to_a
).
to
match_array
([
member1
])
expect
(
result
.
to_a
).
to
match_array
([
member1
])
end
end
it
'does not return nil if `inherited only` relation is requested on root group'
do
group
.
add_developer
(
user2
)
result
=
described_class
.
new
(
group
).
execute
(
include_relations:
[
:inherited
])
expect
(
result
).
not_to
be_nil
end
it
'returns members for descendant groups if requested'
do
it
'returns members for descendant groups if requested'
do
member1
=
group
.
add_maintainer
(
user2
)
member1
=
group
.
add_maintainer
(
user2
)
member2
=
group
.
add_maintainer
(
user1
)
member2
=
group
.
add_maintainer
(
user1
)
...
@@ -71,25 +79,41 @@ describe GroupMembersFinder, '#execute' do
...
@@ -71,25 +79,41 @@ describe GroupMembersFinder, '#execute' do
it
'returns searched members if requested'
do
it
'returns searched members if requested'
do
group
.
add_maintainer
(
user2
)
group
.
add_maintainer
(
user2
)
nested_group
.
add_maintainer
(
user2
)
group
.
add_developer
(
user3
)
nested_group
.
add_maintainer
(
user3
)
nested_group
.
add_maintainer
(
user4
)
member
=
group
.
add_maintainer
(
user1
)
member
=
group
.
add_maintainer
(
user1
)
result
=
described_class
.
new
(
group
).
execute
(
include_relations:
[
:direct
,
:descendants
],
params:
{
search:
user1
.
name
})
result
=
described_class
.
new
(
group
).
execute
(
params:
{
search:
user1
.
name
})
expect
(
result
.
to_a
).
to
match_array
([
member
])
expect
(
result
.
to_a
).
to
match_array
([
member
])
end
end
it
'returns nothing if search only in inherited relation'
do
group
.
add_maintainer
(
user2
)
group
.
add_developer
(
user3
)
group
.
add_maintainer
(
user1
)
result
=
described_class
.
new
(
group
).
execute
(
include_relations:
[
:inherited
],
params:
{
search:
user1
.
name
})
expect
(
result
.
to_a
).
to
match_array
([])
end
it
'returns searched member only from nested_group if search only in inherited relation'
do
group
.
add_maintainer
(
user2
)
group
.
add_developer
(
user3
)
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
})
expect
(
result
.
to_a
).
to
contain_exactly
(
member
)
end
it
'returns members with two-factor auth if requested by owner'
do
it
'returns members with two-factor auth if requested by owner'
do
group
.
add_owner
(
user2
)
group
.
add_owner
(
user2
)
group
.
add_maintainer
(
user1
)
group
.
add_maintainer
(
user1
)
nested_group
.
add_maintainer
(
user2
)
nested_group
.
add_maintainer
(
user3
)
nested_group
.
add_maintainer
(
user4
)
member
=
group
.
add_maintainer
(
user5
)
member
=
group
.
add_maintainer
(
user5
)
result
=
described_class
.
new
(
group
,
user2
).
execute
(
include_relations:
[
:direct
,
:descendants
],
params:
{
two_factor:
'enabled'
})
result
=
described_class
.
new
(
group
,
user2
).
execute
(
params:
{
two_factor:
'enabled'
})
expect
(
result
.
to_a
).
to
contain_exactly
(
member
)
expect
(
result
.
to_a
).
to
contain_exactly
(
member
)
end
end
...
@@ -97,14 +121,11 @@ describe GroupMembersFinder, '#execute' do
...
@@ -97,14 +121,11 @@ describe GroupMembersFinder, '#execute' do
it
'returns members without two-factor auth if requested by owner'
do
it
'returns members without two-factor auth if requested by owner'
do
member1
=
group
.
add_owner
(
user2
)
member1
=
group
.
add_owner
(
user2
)
member2
=
group
.
add_maintainer
(
user1
)
member2
=
group
.
add_maintainer
(
user1
)
nested_group
.
add_maintainer
(
user2
)
member3
=
nested_group
.
add_maintainer
(
user3
)
member4
=
nested_group
.
add_maintainer
(
user4
)
member_with_2fa
=
group
.
add_maintainer
(
user5
)
member_with_2fa
=
group
.
add_maintainer
(
user5
)
result
=
described_class
.
new
(
group
,
user2
).
execute
(
include_relations:
[
:direct
,
:descendants
],
params:
{
two_factor:
'disabled'
})
result
=
described_class
.
new
(
group
,
user2
).
execute
(
params:
{
two_factor:
'disabled'
})
expect
(
result
.
to_a
).
not_to
include
(
member_with_2fa
)
expect
(
result
.
to_a
).
not_to
include
(
member_with_2fa
)
expect
(
result
.
to_a
).
to
match_array
([
member1
,
member2
,
member3
,
member4
])
expect
(
result
.
to_a
).
to
match_array
([
member1
,
member2
])
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