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
2f9d50b7
Commit
2f9d50b7
authored
Mar 24, 2017
by
George Andrinopoulos
Committed by
Rémy Coutable
Mar 24, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "Gitlab administrator cannot create projects in every group"
parent
c0ce9d01
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
2 deletions
+45
-2
app/helpers/namespaces_helper.rb
app/helpers/namespaces_helper.rb
+7
-1
app/views/projects/new.html.haml
app/views/projects/new.html.haml
+1
-1
changelogs/unreleased/27910-admin-can-create-project-in-all-groups.yml
...released/27910-admin-can-create-project-in-all-groups.yml
+4
-0
spec/helpers/namespaces_helper_spec.rb
spec/helpers/namespaces_helper_spec.rb
+33
-0
No files found.
app/helpers/namespaces_helper.rb
View file @
2f9d50b7
...
...
@@ -6,7 +6,13 @@ module NamespacesHelper
def
namespaces_options
(
selected
=
:current_user
,
display_path:
false
,
extra_group:
nil
)
groups
=
current_user
.
owned_groups
+
current_user
.
masters_groups
groups
<<
extra_group
if
extra_group
&&
!
Group
.
exists?
(
name:
extra_group
.
name
)
unless
extra_group
.
nil?
||
extra_group
.
is_a?
(
Group
)
extra_group
=
Group
.
find
(
extra_group
)
if
Namespace
.
find
(
extra_group
).
kind
==
'group'
end
if
extra_group
&&
extra_group
.
is_a?
(
Group
)
&&
(
!
Group
.
exists?
(
name:
extra_group
.
name
)
||
Ability
.
allowed?
(
current_user
,
:read_group
,
extra_group
))
groups
|=
[
extra_group
]
end
users
=
[
current_user
.
namespace
]
...
...
app/views/projects/new.html.haml
View file @
2f9d50b7
...
...
@@ -23,7 +23,7 @@
-
if
current_user
.
can_select_namespace?
.input-group-addon
=
root_url
=
f
.
select
:namespace_id
,
namespaces_options
(
namespace_id_from
(
params
)
||
:current_user
,
display_path:
true
),
{},
{
class:
'select2 js-select-namespace'
,
tabindex:
1
}
=
f
.
select
:namespace_id
,
namespaces_options
(
namespace_id_from
(
params
)
||
:current_user
,
display_path:
true
,
extra_group:
namespace_id_from
(
params
)),
{},
{
class:
'select2 js-select-namespace'
,
tabindex:
1
}
-
else
.input-group-addon.static-namespace
...
...
changelogs/unreleased/27910-admin-can-create-project-in-all-groups.yml
0 → 100644
View file @
2f9d50b7
---
title
:
Allow admin to view all namespaces
merge_request
:
author
:
George Andrinopoulos
spec/helpers/namespaces_helper_spec.rb
0 → 100644
View file @
2f9d50b7
require
'spec_helper'
describe
NamespacesHelper
,
type: :helper
do
let!
(
:admin
)
{
create
(
:admin
)
}
let!
(
:admin_group
)
{
create
(
:group
,
:private
)
}
let!
(
:user
)
{
create
(
:user
)
}
let!
(
:user_group
)
{
create
(
:group
,
:private
)
}
before
do
admin_group
.
add_owner
(
admin
)
user_group
.
add_owner
(
user
)
end
describe
'#namespaces_options'
do
it
'returns groups without being a member for admin'
do
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
admin
)
options
=
helper
.
namespaces_options
(
user_group
.
id
,
display_path:
true
,
extra_group:
user_group
.
id
)
expect
(
options
).
to
include
(
admin_group
.
name
)
expect
(
options
).
to
include
(
user_group
.
name
)
end
it
'returns only allowed namespaces for user'
do
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
user
)
options
=
helper
.
namespaces_options
expect
(
options
).
not_to
include
(
admin_group
.
name
)
expect
(
options
).
to
include
(
user_group
.
name
)
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