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
60ecf83a
Commit
60ecf83a
authored
Sep 09, 2020
by
Małgorzata Ksionek
Committed by
Jan Provaznik
Sep 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modify member method
Fix groups sharing method Update scope Fix wording
parent
a4a823ab
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
10 deletions
+45
-10
app/models/group.rb
app/models/group.rb
+1
-1
app/models/member.rb
app/models/member.rb
+3
-0
ee/app/models/ee/group.rb
ee/app/models/ee/group.rb
+5
-1
spec/finders/groups_finder_spec.rb
spec/finders/groups_finder_spec.rb
+8
-8
spec/models/member_spec.rb
spec/models/member_spec.rb
+28
-0
No files found.
app/models/group.rb
View file @
60ecf83a
...
@@ -347,7 +347,6 @@ class Group < Namespace
...
@@ -347,7 +347,6 @@ class Group < Namespace
end
end
group_hierarchy_members
=
GroupMember
.
active_without_invites_and_requests
group_hierarchy_members
=
GroupMember
.
active_without_invites_and_requests
.
non_minimal_access
.
where
(
source_id:
source_ids
)
.
where
(
source_id:
source_ids
)
GroupMember
.
from_union
([
group_hierarchy_members
,
GroupMember
.
from_union
([
group_hierarchy_members
,
...
@@ -637,6 +636,7 @@ class Group < Namespace
...
@@ -637,6 +636,7 @@ class Group < Namespace
.
where
(
group_member_table
[
:requested_at
].
eq
(
nil
))
.
where
(
group_member_table
[
:requested_at
].
eq
(
nil
))
.
where
(
group_member_table
[
:source_id
].
eq
(
group_group_link_table
[
:shared_with_group_id
]))
.
where
(
group_member_table
[
:source_id
].
eq
(
group_group_link_table
[
:shared_with_group_id
]))
.
where
(
group_member_table
[
:source_type
].
eq
(
'Namespace'
))
.
where
(
group_member_table
[
:source_type
].
eq
(
'Namespace'
))
.
non_minimal_access
end
end
def
smallest_value_arel
(
args
,
column_alias
)
def
smallest_value_arel
(
args
,
column_alias
)
...
...
app/models/member.rb
View file @
60ecf83a
...
@@ -59,6 +59,7 @@ class Member < ApplicationRecord
...
@@ -59,6 +59,7 @@ class Member < ApplicationRecord
left_join_users
left_join_users
.
where
(
user_ok
)
.
where
(
user_ok
)
.
where
(
requested_at:
nil
)
.
where
(
requested_at:
nil
)
.
non_minimal_access
.
reorder
(
nil
)
.
reorder
(
nil
)
end
end
...
@@ -67,6 +68,8 @@ class Member < ApplicationRecord
...
@@ -67,6 +68,8 @@ class Member < ApplicationRecord
left_join_users
left_join_users
.
where
(
users:
{
state:
'active'
})
.
where
(
users:
{
state:
'active'
})
.
non_request
.
non_request
.
non_invite
.
non_minimal_access
.
reorder
(
nil
)
.
reorder
(
nil
)
end
end
...
...
ee/app/models/ee/group.rb
View file @
60ecf83a
...
@@ -407,7 +407,11 @@ module EE
...
@@ -407,7 +407,11 @@ module EE
override
:member?
override
:member?
def
member?
(
user
,
min_access_level
=
minimal_member_access_level
)
def
member?
(
user
,
min_access_level
=
minimal_member_access_level
)
super
if
min_access_level
==
::
Gitlab
::
Access
::
MINIMAL_ACCESS
&&
minimal_access_role_allowed?
all_group_members
.
find_by
(
user_id:
user
.
id
).
present?
else
super
end
end
end
def
minimal_member_access_level
def
minimal_member_access_level
...
...
spec/finders/groups_finder_spec.rb
View file @
60ecf83a
...
@@ -106,14 +106,6 @@ RSpec.describe GroupsFinder do
...
@@ -106,14 +106,6 @@ RSpec.describe GroupsFinder do
parent_group
.
update_attribute
(
:visibility_level
,
Gitlab
::
VisibilityLevel
::
PRIVATE
)
parent_group
.
update_attribute
(
:visibility_level
,
Gitlab
::
VisibilityLevel
::
PRIVATE
)
end
end
context
'being limited access member of parent group'
do
it
'do not return group with minimal_access access'
do
create
(
:group_member
,
:minimal_access
,
user:
user
,
group:
parent_group
)
is_expected
.
to
contain_exactly
(
public_subgroup
,
internal_subgroup
)
end
end
context
'being member of parent group'
do
context
'being member of parent group'
do
it
'returns all subgroups'
do
it
'returns all subgroups'
do
parent_group
.
add_guest
(
user
)
parent_group
.
add_guest
(
user
)
...
@@ -158,6 +150,14 @@ RSpec.describe GroupsFinder do
...
@@ -158,6 +150,14 @@ RSpec.describe GroupsFinder do
end
end
end
end
end
end
context
'being minimal access member of parent group'
do
it
'do not return group with minimal_access access'
do
create
(
:group_member
,
:minimal_access
,
user:
user
,
group:
parent_group
)
is_expected
.
to
contain_exactly
(
public_subgroup
,
internal_subgroup
)
end
end
end
end
end
end
end
end
...
...
spec/models/member_spec.rb
View file @
60ecf83a
...
@@ -266,6 +266,34 @@ RSpec.describe Member do
...
@@ -266,6 +266,34 @@ RSpec.describe Member do
it
{
is_expected
.
not_to
include
@blocked_maintainer
}
it
{
is_expected
.
not_to
include
@blocked_maintainer
}
it
{
is_expected
.
not_to
include
@blocked_developer
}
it
{
is_expected
.
not_to
include
@blocked_developer
}
end
end
describe
'.active'
do
subject
{
described_class
.
active
.
to_a
}
it
{
is_expected
.
to
include
@owner
}
it
{
is_expected
.
to
include
@maintainer
}
it
{
is_expected
.
to
include
@invited_member
}
it
{
is_expected
.
to
include
@accepted_invite_member
}
it
{
is_expected
.
not_to
include
@requested_member
}
it
{
is_expected
.
to
include
@accepted_request_member
}
it
{
is_expected
.
not_to
include
@blocked_maintainer
}
it
{
is_expected
.
not_to
include
@blocked_developer
}
it
{
is_expected
.
not_to
include
@member_with_minimal_access
}
end
describe
'.active_without_invites_and_requests'
do
subject
{
described_class
.
active_without_invites_and_requests
.
to_a
}
it
{
is_expected
.
to
include
@owner
}
it
{
is_expected
.
to
include
@maintainer
}
it
{
is_expected
.
not_to
include
@invited_member
}
it
{
is_expected
.
to
include
@accepted_invite_member
}
it
{
is_expected
.
not_to
include
@requested_member
}
it
{
is_expected
.
to
include
@accepted_request_member
}
it
{
is_expected
.
not_to
include
@blocked_maintainer
}
it
{
is_expected
.
not_to
include
@blocked_developer
}
it
{
is_expected
.
not_to
include
@member_with_minimal_access
}
end
end
end
describe
"Delegate methods"
do
describe
"Delegate methods"
do
...
...
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