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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
c6701fef
Commit
c6701fef
authored
Mar 27, 2017
by
Fabio Huser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(subgroups): add verification of group creation capability to subgroup UI
parent
ad831ace
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
1 deletion
+27
-1
app/models/user.rb
app/models/user.rb
+4
-0
app/views/groups/subgroups.html.haml
app/views/groups/subgroups.html.haml
+1
-1
spec/models/user_spec.rb
spec/models/user_spec.rb
+22
-0
No files found.
app/models/user.rb
View file @
c6701fef
...
@@ -570,6 +570,10 @@ class User < ActiveRecord::Base
...
@@ -570,6 +570,10 @@ class User < ActiveRecord::Base
can?
(
:create_group
)
can?
(
:create_group
)
end
end
def
can_create_subgroup?
(
group
)
can?
(
:create_group
)
&&
can?
(
:admin_group
,
group
)
end
def
can_select_namespace?
def
can_select_namespace?
several_namespaces?
||
admin
several_namespaces?
||
admin
end
end
...
...
app/views/groups/subgroups.html.haml
View file @
c6701fef
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
.nav-controls
.nav-controls
=
form_tag
request
.
path
,
method: :get
do
|
f
|
=
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
=
search_field_tag
:filter_groups
,
params
[
:filter_groups
],
placeholder:
'Filter by name'
,
class:
'form-control'
,
spellcheck:
false
-
if
c
an?
current_user
,
:admin_group
,
@group
-
if
c
urrent_user
.
can_create_subgroup?
@group
=
link_to
new_group_path
(
parent_id:
@group
.
id
),
class:
'btn btn-new pull-right'
do
=
link_to
new_group_path
(
parent_id:
@group
.
id
),
class:
'btn btn-new pull-right'
do
New Subgroup
New Subgroup
...
...
spec/models/user_spec.rb
View file @
c6701fef
...
@@ -464,6 +464,28 @@ describe User, models: true do
...
@@ -464,6 +464,28 @@ describe User, models: true do
it
{
expect
(
@user2
.
several_namespaces?
).
to
be_truthy
}
it
{
expect
(
@user2
.
several_namespaces?
).
to
be_truthy
}
end
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
describe
'namespaced'
do
before
do
before
do
@user
=
create
:user
@user
=
create
:user
...
...
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