BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
525ea066
Unverified
Commit
525ea066
authored
Apr 11, 2017
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move permission to create subgroup into GroupPolicy
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
c6701fef
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
8 additions
and
28 deletions
+8
-28
user.rb
app/models/user.rb
+0
-4
group_policy.rb
app/policies/group_policy.rb
+1
-0
subgroups.html.haml
app/views/groups/subgroups.html.haml
+1
-1
siemens-gitlab-ce-fix-subgroup-hide-button.yml
...unreleased/siemens-gitlab-ce-fix-subgroup-hide-button.yml
+4
-0
user_spec.rb
spec/models/user_spec.rb
+0
-22
group_policy_spec.rb
spec/policies/group_policy_spec.rb
+2
-1
No files found.
app/models/user.rb
View file @
525ea066
...
...
@@ -570,10 +570,6 @@ class User < ActiveRecord::Base
can?
(
:create_group
)
end
def
can_create_subgroup?
(
group
)
can?
(
:create_group
)
&&
can?
(
:admin_group
,
group
)
end
def
can_select_namespace?
several_namespaces?
||
admin
end
...
...
app/policies/group_policy.rb
View file @
525ea066
...
...
@@ -28,6 +28,7 @@ class GroupPolicy < BasePolicy
can!
:admin_namespace
can!
:admin_group_member
can!
:change_visibility_level
can!
:create_subgroup
if
@user
.
can_create_group
end
if
globally_viewable
&&
@subject
.
request_access_enabled
&&
!
member
...
...
app/views/groups/subgroups.html.haml
View file @
525ea066
...
...
@@ -9,7 +9,7 @@
.nav-controls
=
form_tag
request
.
path
,
method: :get
do
|
f
|
=
search_field_tag
:filter_groups
,
params
[
:filter_groups
],
placeholder:
'Filter by name'
,
class:
'form-control'
,
spellcheck:
false
-
if
c
urrent_user
.
can_create_subgroup?
@group
-
if
c
an?
(
current_user
,
:create_subgroup
,
@group
)
=
link_to
new_group_path
(
parent_id:
@group
.
id
),
class:
'btn btn-new pull-right'
do
New Subgroup
...
...
changelogs/unreleased/siemens-gitlab-ce-fix-subgroup-hide-button.yml
0 → 100644
View file @
525ea066
---
title
:
Hide new subgroup button if user has no permission to create one
merge_request
:
author
:
spec/models/user_spec.rb
View file @
525ea066
...
...
@@ -464,28 +464,6 @@ describe User, models: true do
it
{
expect
(
@user2
.
several_namespaces?
).
to
be_truthy
}
end
describe
'subgroups'
do
let
(
:group
)
{
create
:group
}
it
'allows if owner'
do
user
=
create
:user
group
.
add_user
(
user
,
GroupMember
::
OWNER
)
expect
(
user
.
can_create_subgroup?
(
group
)).
to
be_truthy
end
it
'disallows if missing right'
do
user
=
create
(
:user
,
can_create_group:
false
)
group
.
add_user
(
user
,
GroupMember
::
MASTER
)
expect
(
user
.
can_create_subgroup?
(
group
)).
to
be_falsey
end
it
'disallows if developer'
do
user
=
create
:user
group
.
add_user
(
user
,
GroupMember
::
DEVELOPER
)
expect
(
user
.
can_create_subgroup?
(
group
)).
to
be_falsey
end
end
describe
'namespaced'
do
before
do
@user
=
create
:user
...
...
spec/policies/group_policy_spec.rb
View file @
525ea066
...
...
@@ -22,7 +22,8 @@ describe GroupPolicy, models: true do
:admin_group
,
:admin_namespace
,
:admin_group_member
,
:change_visibility_level
:change_visibility_level
,
:create_subgroup
]
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