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
5404dbb4
Commit
5404dbb4
authored
Sep 05, 2017
by
Michael Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix ability when Share lock is off
parent
45601cba
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
45 deletions
+62
-45
app/policies/group_policy.rb
app/policies/group_policy.rb
+2
-1
spec/policies/group_policy_spec.rb
spec/policies/group_policy_spec.rb
+60
-44
No files found.
app/policies/group_policy.rb
View file @
5404dbb4
...
...
@@ -15,6 +15,7 @@ class GroupPolicy < BasePolicy
condition
(
:nested_groups_supported
,
scope: :global
)
{
Group
.
supports_nested_groups?
}
condition
(
:share_locked
,
scope: :subject
)
{
@subject
.
share_with_group_lock?
}
condition
(
:parent_share_locked
,
scope: :subject
)
{
@subject
.
parent
&
.
share_with_group_lock?
}
condition
(
:can_change_parent_share_with_group_lock
)
{
@subject
.
has_parent?
&&
can?
(
:change_share_with_group_lock
,
@subject
.
parent
)
}
...
...
@@ -57,7 +58,7 @@ class GroupPolicy < BasePolicy
rule
{
~
can?
(
:view_globally
)
}.
prevent
:request_access
rule
{
has_access
}.
prevent
:request_access
rule
{
owner
&
(
~
parent_share_locked
|
can_change_parent_share_with_group_lock
)
}.
enable
:change_share_with_group_lock
rule
{
owner
&
(
~
share_locked
|
~
parent_share_locked
|
can_change_parent_share_with_group_lock
)
}.
enable
:change_share_with_group_lock
def
access_level
return
GroupMember
::
NO_ACCESS
if
@user
.
nil?
...
...
spec/policies/group_policy_spec.rb
View file @
5404dbb4
...
...
@@ -244,76 +244,92 @@ describe GroupPolicy do
end
describe
'change_share_with_group_lock'
do
context
'when the
group has a parent'
,
:nested_groups
do
let
(
:
group
)
{
create
(
:group
,
parent:
parent
)
}
context
'when the
current_user owns the group'
do
let
(
:
current_user
)
{
owner
}
context
'when the
parent
share_with_group_lock is enabled'
do
let
(
:
current_user
)
{
owner
}
context
'when the
group
share_with_group_lock is enabled'
do
let
(
:
group
)
{
create
(
:group
,
share_with_group_lock:
true
,
parent:
parent
)
}
context
'when the
group has a grandparent
'
do
let
(
:grandparent
)
{
create
(
:group
,
share_with_group_lock:
true
)
}
let
(
:parent
)
{
create
(
:group
,
share_with_group_lock:
true
,
parent:
grandparent
)
}
context
'when the
parent group share_with_group_lock is enabled
'
do
context
'when the group has a grandparent'
do
let
(
:parent
)
{
create
(
:group
,
share_with_group_lock:
true
,
parent:
grandparent
)
}
context
'and the grandparent share_with_group_lock is enabled'
do
context
'when current_user owns the grandparent'
do
before
do
grandparent
.
add_owner
(
owner
)
context
'when the grandparent share_with_group_lock is enabled'
do
let
(
:grandparent
)
{
create
(
:group
,
share_with_group_lock:
true
)
}
context
'when the current_user owns the parent'
do
before
do
parent
.
add_owner
(
current_user
)
end
context
'when the current_user owns the grandparent'
do
before
do
grandparent
.
add_owner
(
current_user
)
end
it
{
expect_allowed
(
:change_share_with_group_lock
)
}
end
context
'when the current_user does not own the grandparent'
do
it
{
expect_disallowed
(
:change_share_with_group_lock
)
}
end
end
it
{
expect_allowed
(
:change_share_with_group_lock
)
}
context
'when the current_user does not own the parent'
do
it
{
expect_disallowed
(
:change_share_with_group_lock
)
}
end
end
context
'when current_user owns the parent but not the grandparent'
do
before
do
parent
.
add_owner
(
owner
)
context
'when the grandparent share_with_group_lock is disabled'
do
let
(
:grandparent
)
{
create
(
:group
)
}
context
'when the current_user owns the parent'
do
before
do
parent
.
add_owner
(
current_user
)
end
it
{
expect_allowed
(
:change_share_with_group_lock
)
}
end
it
{
expect_disallowed
(
:change_share_with_group_lock
)
}
context
'when the current_user does not own the parent'
do
it
{
expect_disallowed
(
:change_share_with_group_lock
)
}
end
end
end
end
context
'when the group does not have a grandparent'
do
let
(
:parent
)
{
create
(
:group
,
share_with_group_lock:
true
)
}
context
'when the group does not have a grandparent'
do
let
(
:parent
)
{
create
(
:group
,
share_with_group_lock:
true
)
}
context
'when
current_user owns the parent'
do
before
do
parent
.
add_owner
(
own
er
)
end
context
'when the
current_user owns the parent'
do
before
do
parent
.
add_owner
(
current_us
er
)
end
it
{
expect_allowed
(
:change_share_with_group_lock
)
}
end
it
{
expect_allowed
(
:change_share_with_group_lock
)
}
end
context
'when current_user owns the group but not the parent'
do
it
{
expect_disallowed
(
:change_share_with_group_lock
)
}
context
'when the current_user does not own the parent'
do
it
{
expect_disallowed
(
:change_share_with_group_lock
)
}
end
end
end
end
context
'when the parent share_with_group_lock is disabled'
do
let
(
:parent
)
{
create
(
:group
)
}
let
(
:current_user
)
{
owner
}
context
'when current_user owns the parent'
do
before
do
parent
.
add_owner
(
owner
)
end
context
'when the parent group share_with_group_lock is disabled'
do
let
(
:parent
)
{
create
(
:group
)
}
it
{
expect_allowed
(
:change_share_with_group_lock
)
}
end
end
context
'when current_user owns the group but not the parent'
do
it
{
expect_allowed
(
:change_share_with_group_lock
)
}
end
context
'when the group share_with_group_lock is disabled'
do
it
{
expect_allowed
(
:change_share_with_group_lock
)
}
end
end
context
'when the group does not have a parent'
do
context
'when current_user owns the group'
do
let
(
:current_user
)
{
owner
}
context
'when the current_user does not own the group'
do
let
(
:current_user
)
{
create
(
:user
)
}
it
{
expect_allowed
(
:change_share_with_group_lock
)
}
end
it
{
expect_disallowed
(
:change_share_with_group_lock
)
}
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