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
23fc1f66
Commit
23fc1f66
authored
Dec 29, 2016
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dz-nested-group-misc' into 'master'
Miscellaneous improvements to the nested groups feature See merge request !8308
parents
714f70a3
283e868e
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
62 additions
and
4 deletions
+62
-4
groups_controller.rb
app/controllers/groups_controller.rb
+2
-0
create_service.rb
app/services/groups/create_service.rb
+7
-0
show.html.haml
app/views/groups/show.html.haml
+9
-0
dz-nested-group-misc.yml
changelogs/unreleased/dz-nested-group-misc.yml
+4
-0
groups_spec.rb
spec/features/groups_spec.rb
+13
-0
create_service_spec.rb
spec/services/groups/create_service_spec.rb
+27
-4
No files found.
app/controllers/groups_controller.rb
View file @
23fc1f66
...
...
@@ -42,6 +42,8 @@ class GroupsController < Groups::ApplicationController
@notification_setting
=
current_user
.
notification_settings_for
(
group
)
end
@nested_groups
=
group
.
children
setup_projects
respond_to
do
|
format
|
...
...
app/services/groups/create_service.rb
View file @
23fc1f66
...
...
@@ -12,6 +12,13 @@ module Groups
return
@group
end
if
@group
.
parent
&&
!
can?
(
current_user
,
:admin_group
,
@group
.
parent
)
@group
.
parent
=
nil
@group
.
errors
.
add
(
:parent_id
,
'manage access required to create subgroup'
)
return
@group
end
@group
.
name
||=
@group
.
path
.
dup
@group
.
save
@group
.
add_owner
(
current_user
)
...
...
app/views/groups/show.html.haml
View file @
23fc1f66
...
...
@@ -32,6 +32,10 @@
%li
=
link_to
"#shared"
,
'data-toggle'
=>
'tab'
do
Shared Projects
-
if
@nested_groups
.
present?
%li
=
link_to
"#groups"
,
'data-toggle'
=>
'tab'
do
Subgroups
.nav-controls
=
form_tag
request
.
path
,
method: :get
,
class:
'project-filter-form'
,
id:
'project-filter-form'
do
|
f
|
=
search_field_tag
:filter_projects
,
nil
,
placeholder:
'Filter by name'
,
class:
'projects-list-filter form-control'
,
spellcheck:
false
...
...
@@ -47,3 +51,8 @@
-
if
@shared_projects
.
present?
.tab-pane
#shared
=
render
"shared_projects"
,
projects:
@shared_projects
-
if
@nested_groups
.
present?
.tab-pane
#groups
%ul
.content-list
=
render
partial:
'shared/groups/group'
,
collection:
@nested_groups
changelogs/unreleased/dz-nested-group-misc.yml
0 → 100644
View file @
23fc1f66
---
title
:
Show nested groups tab on group page
merge_request
:
8308
author
:
spec/features/groups_spec.rb
View file @
23fc1f66
...
...
@@ -107,4 +107,17 @@ feature 'Group', feature: true do
expect
(
page
).
to
have_css
(
'.group-home-desc a[rel]'
)
end
end
describe
'group page with nested groups'
,
js:
true
do
let!
(
:group
)
{
create
(
:group
)
}
let!
(
:nested_group
)
{
create
(
:group
,
parent:
group
)
}
let!
(
:path
)
{
group_path
(
group
)
}
it
'has nested groups tab with nested groups inside'
do
visit
path
click_link
'Subgroups'
expect
(
page
).
to
have_content
(
nested_group
.
full_name
)
end
end
end
spec/services/groups/create_service_spec.rb
View file @
23fc1f66
require
'spec_helper'
describe
Groups
::
CreateService
,
services:
true
do
let!
(
:user
)
{
create
(
:user
)
}
describe
Groups
::
CreateService
,
'#execute'
,
services:
true
do
let!
(
:user
)
{
create
(
:user
)
}
let!
(
:group_params
)
{
{
path:
"group_path"
,
visibility_level:
Gitlab
::
VisibilityLevel
::
PUBLIC
}
}
describe
"execute"
do
let!
(
:service
)
{
described_class
.
new
(
user
,
group_params
)
}
describe
'visibility level restrictions'
do
let!
(
:service
)
{
described_class
.
new
(
user
,
group_params
)
}
subject
{
service
.
execute
}
context
"create groups without restricted visibility level"
do
...
...
@@ -14,7 +15,29 @@ describe Groups::CreateService, services: true do
context
"cannot create group with restricted visibility level"
do
before
{
allow_any_instance_of
(
ApplicationSetting
).
to
receive
(
:restricted_visibility_levels
).
and_return
([
Gitlab
::
VisibilityLevel
::
PUBLIC
])
}
it
{
is_expected
.
not_to
be_persisted
}
end
end
describe
'creating subgroup'
do
let!
(
:group
)
{
create
(
:group
)
}
let!
(
:service
)
{
described_class
.
new
(
user
,
group_params
.
merge
(
parent_id:
group
.
id
))
}
subject
{
service
.
execute
}
context
'as group owner'
do
before
{
group
.
add_owner
(
user
)
}
it
{
is_expected
.
to
be_persisted
}
end
context
'as guest'
do
it
'does not save group and returns an error'
do
is_expected
.
not_to
be_persisted
expect
(
subject
.
errors
[
:parent_id
].
first
).
to
eq
(
'manage access required to create subgroup'
)
expect
(
subject
.
parent_id
).
to
be_nil
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