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
Boxiang Sun
gitlab-ce
Commits
13d9c5dd
Commit
13d9c5dd
authored
Jun 28, 2019
by
Fabio Papa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Style rules; Revert some examples
parent
ec802d64
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
52 additions
and
22 deletions
+52
-22
db/migrate/20190626175626_add_group_creation_level_to_namespaces.rb
.../20190626175626_add_group_creation_level_to_namespaces.rb
+5
-2
spec/controllers/admin/groups_controller_spec.rb
spec/controllers/admin/groups_controller_spec.rb
+7
-2
spec/features/groups/group_settings_spec.rb
spec/features/groups/group_settings_spec.rb
+1
-1
spec/features/groups/show_spec.rb
spec/features/groups/show_spec.rb
+17
-7
spec/models/group_spec.rb
spec/models/group_spec.rb
+2
-1
spec/policies/group_policy_spec.rb
spec/policies/group_policy_spec.rb
+16
-5
spec/requests/api/groups_spec.rb
spec/requests/api/groups_spec.rb
+2
-2
spec/services/groups/create_service_spec.rb
spec/services/groups/create_service_spec.rb
+2
-2
No files found.
db/migrate/20190626175626_add_group_creation_level_to_namespaces.rb
View file @
13d9c5dd
...
...
@@ -5,10 +5,13 @@ class AddGroupCreationLevelToNamespaces < ActiveRecord::Migration[5.1]
DOWNTIME
=
false
disable_ddl_transaction!
def
up
unless
column_exists?
(
:namespaces
,
:subgroup_creation_level
)
add_column_with_default
(
:namespaces
,
:subgroup_creation_level
,
:integer
,
default:
0
)
add_column_with_default
(
:namespaces
,
:subgroup_creation_level
,
:integer
,
default:
0
)
end
end
...
...
spec/controllers/admin/groups_controller_spec.rb
View file @
13d9c5dd
...
...
@@ -70,9 +70,14 @@ describe Admin::GroupsController do
end
it
'updates the subgroup_creation_level successfully'
do
MAINTAINER
=
::
Gitlab
::
Access
::
MAINTAINER_SUBGROUP_ACCESS
expect
do
post
:update
,
params:
{
id:
group
.
to_param
,
group:
{
subgroup_creation_level:
::
Gitlab
::
Access
::
MAINTAINER_SUBGROUP_ACCESS
}
}
end
.
to
change
{
group
.
reload
.
subgroup_creation_level
}.
to
(
::
Gitlab
::
Access
::
MAINTAINER_SUBGROUP_ACCESS
)
post
:update
,
params:
{
id:
group
.
to_param
,
group:
{
subgroup_creation_level:
MAINTAINER
}
}
end
.
to
change
{
group
.
reload
.
subgroup_creation_level
}
.
to
(
MAINTAINER
)
end
end
end
spec/features/groups/group_settings_spec.rb
View file @
13d9c5dd
...
...
@@ -92,7 +92,7 @@ describe 'Edit group settings' do
expect
(
page
).
to
have_content
(
'Allowed to create subgroups'
)
end
end
describe
'edit group avatar'
do
before
do
visit
edit_group_path
(
group
)
...
...
spec/features/groups/show_spec.rb
View file @
13d9c5dd
...
...
@@ -76,7 +76,8 @@ describe 'Group show page' do
end
it
'allows creating subgroups'
do
expect
(
page
).
to
have_css
(
"li[data-text='New subgroup']"
,
visible:
false
)
expect
(
page
)
.
to
have_css
(
"li[data-text='New subgroup']"
,
visible:
false
)
end
end
...
...
@@ -87,7 +88,8 @@ describe 'Group show page' do
end
it
'does not allow creating subgroups'
do
expect
(
page
).
not_to
have_selector
(
"li[data-text='New subgroup']"
,
visible:
false
)
expect
(
page
)
.
not_to
have_selector
(
"li[data-text='New subgroup']"
,
visible:
false
)
end
end
end
...
...
@@ -104,8 +106,11 @@ describe 'Group show page' do
end
context
'when subgroup_creation_level is set to maintainer'
do
let
(
:group
)
{
create
(
:group
,
subgroup_creation_level:
::
Gitlab
::
Access
::
MAINTAINER_SUBGROUP_ACCESS
)
}
let
(
:group
)
do
create
(
:group
,
subgroup_creation_level:
::
Gitlab
::
Access
::
MAINTAINER_SUBGROUP_ACCESS
)
end
it
'allows creating subgroups'
do
visit
path
expect
(
page
).
to
have_css
(
"li[data-text='New subgroup']"
,
visible:
false
)
...
...
@@ -113,11 +118,15 @@ describe 'Group show page' do
end
context
'when subgroup_creation_level is set to owners'
do
let
(
:group
)
{
create
(
:group
,
subgroup_creation_level:
::
Gitlab
::
Access
::
OWNER_SUBGROUP_ACCESS
)
}
let
(
:group
)
do
create
(
:group
,
subgroup_creation_level:
::
Gitlab
::
Access
::
OWNER_SUBGROUP_ACCESS
)
end
it
'does not allow creating subgroups'
do
visit
path
expect
(
page
).
not_to
have_css
(
"li[data-text='New subgroup']"
,
visible:
false
)
expect
(
page
)
.
not_to
have_css
(
"li[data-text='New subgroup']"
,
visible:
false
)
end
end
end
...
...
@@ -129,7 +138,8 @@ describe 'Group show page' do
end
it
'does not allow creating subgroups'
do
expect
(
page
).
not_to
have_selector
(
"li[data-text='New subgroup']"
,
visible:
false
)
expect
(
page
)
.
not_to
have_selector
(
"li[data-text='New subgroup']"
,
visible:
false
)
end
end
end
...
...
spec/models/group_spec.rb
View file @
13d9c5dd
...
...
@@ -999,7 +999,8 @@ describe Group do
it
'outputs the default one if it is nil'
do
group
=
create
(
:group
,
subgroup_creation_level:
nil
)
expect
(
group
.
subgroup_creation_level
).
to
eq
(
::
Gitlab
::
Access
::
MAINTAINER_SUBGROUP_ACCESS
)
expect
(
group
.
subgroup_creation_level
)
.
to
eq
(
::
Gitlab
::
Access
::
MAINTAINER_SUBGROUP_ACCESS
)
end
end
end
spec/policies/group_policy_spec.rb
View file @
13d9c5dd
...
...
@@ -145,7 +145,8 @@ describe GroupPolicy do
it
'allows every owner permission except creating subgroups'
do
create_subgroup_permission
=
[
:create_subgroup
]
updated_owner_permissions
=
owner_permissions
-
create_subgroup_permission
updated_owner_permissions
=
owner_permissions
-
create_subgroup_permission
expect_disallowed
(
*
create_subgroup_permission
)
expect_allowed
(
*
updated_owner_permissions
)
...
...
@@ -157,7 +158,8 @@ describe GroupPolicy do
it
'allows every owner permission except creating subgroups'
do
create_subgroup_permission
=
[
:create_subgroup
]
updated_owner_permissions
=
owner_permissions
-
create_subgroup_permission
updated_owner_permissions
=
owner_permissions
-
create_subgroup_permission
expect_disallowed
(
*
create_subgroup_permission
)
expect_allowed
(
*
updated_owner_permissions
)
...
...
@@ -169,7 +171,8 @@ describe GroupPolicy do
it
'allows every maintainer permission except creating subgroups'
do
create_subgroup_permission
=
[
:create_subgroup
]
updated_maintainer_permissions
=
maintainer_permissions
-
create_subgroup_permission
updated_maintainer_permissions
=
maintainer_permissions
-
create_subgroup_permission
expect_disallowed
(
*
create_subgroup_permission
)
expect_allowed
(
*
updated_maintainer_permissions
)
...
...
@@ -475,7 +478,11 @@ describe GroupPolicy do
context
"create_subgroup"
do
context
'when group has subgroup creation level set to owner'
do
let
(
:group
)
{
create
(
:group
,
subgroup_creation_level:
::
Gitlab
::
Access
::
OWNER_SUBGROUP_ACCESS
)
}
let
(
:group
)
do
create
(
:group
,
subgroup_creation_level:
::
Gitlab
::
Access
::
OWNER_SUBGROUP_ACCESS
)
end
context
'reporter'
do
let
(
:current_user
)
{
reporter
}
...
...
@@ -503,7 +510,11 @@ describe GroupPolicy do
end
context
'when group has subgroup creation level set to maintainer'
do
let
(
:group
)
{
create
(
:group
,
subgroup_creation_level:
::
Gitlab
::
Access
::
MAINTAINER_SUBGROUP_ACCESS
)
}
let
(
:group
)
do
create
(
:group
,
subgroup_creation_level:
::
Gitlab
::
Access
::
MAINTAINER_SUBGROUP_ACCESS
)
end
context
'reporter'
do
let
(
:current_user
)
{
reporter
}
...
...
spec/requests/api/groups_spec.rb
View file @
13d9c5dd
...
...
@@ -803,10 +803,10 @@ describe API::Groups do
group2
.
add_maintainer
(
user1
)
end
it
'can create subgroups'
do
it
'can
not
create subgroups'
do
post
api
(
"/groups"
,
user1
),
params:
{
parent_id:
group2
.
id
,
name:
'foo'
,
path:
'foo'
}
expect
(
response
).
to
have_gitlab_http_status
(
201
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
end
end
end
...
...
spec/services/groups/create_service_spec.rb
View file @
13d9c5dd
...
...
@@ -89,9 +89,9 @@ describe Groups::CreateService, '#execute' do
it
{
is_expected
.
to
be_persisted
}
end
context
'as
maintai
ner'
do
context
'as
Ow
ner'
do
before
do
group
.
add_
maintai
ner
(
user
)
group
.
add_
ow
ner
(
user
)
end
it
{
is_expected
.
to
be_persisted
}
...
...
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