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
3f7b7a3b
Commit
3f7b7a3b
authored
Feb 20, 2017
by
David Piegza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix preselected namespace when creating a project
parent
2338ac73
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
1 deletion
+50
-1
app/helpers/namespaces_helper.rb
app/helpers/namespaces_helper.rb
+4
-0
app/views/projects/new.html.haml
app/views/projects/new.html.haml
+1
-1
spec/features/projects/new_project_spec.rb
spec/features/projects/new_project_spec.rb
+45
-0
No files found.
app/helpers/namespaces_helper.rb
View file @
3f7b7a3b
module
NamespacesHelper
module
NamespacesHelper
def
namespace_id_from
(
params
)
params
.
dig
(
:project
,
:namespace_id
)
||
params
[
:namespace_id
]
end
def
namespaces_options
(
selected
=
:current_user
,
display_path:
false
,
extra_group:
nil
)
def
namespaces_options
(
selected
=
:current_user
,
display_path:
false
,
extra_group:
nil
)
groups
=
current_user
.
owned_groups
+
current_user
.
masters_groups
groups
=
current_user
.
owned_groups
+
current_user
.
masters_groups
...
...
app/views/projects/new.html.haml
View file @
3f7b7a3b
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
-
if
current_user
.
can_select_namespace?
-
if
current_user
.
can_select_namespace?
.input-group-addon
.input-group-addon
=
root_url
=
root_url
=
f
.
select
:namespace_id
,
namespaces_options
(
params
[
:namespace_id
]
||
: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
),
{},
{
class:
'select2 js-select-namespace'
,
tabindex:
1
}
-
else
-
else
.input-group-addon.static-namespace
.input-group-addon.static-namespace
...
...
spec/features/projects/new_project_spec.rb
View file @
3f7b7a3b
...
@@ -19,6 +19,51 @@ feature "New project", feature: true do
...
@@ -19,6 +19,51 @@ feature "New project", feature: true do
end
end
end
end
context
"Namespace selector"
do
context
"with user namespace"
do
before
do
visit
new_project_path
end
it
"selects the user namespace"
do
namespace
=
find
(
"#project_namespace_id"
)
expect
(
namespace
.
text
).
to
eq
user
.
username
end
end
context
"with group namespace"
do
let
(
:group
)
{
create
(
:group
,
:private
,
owner:
user
)
}
before
do
group
.
add_owner
(
user
)
visit
new_project_path
(
namespace_id:
group
.
id
)
end
it
"selects the group namespace"
do
namespace
=
find
(
"#project_namespace_id option[selected]"
)
expect
(
namespace
.
text
).
to
eq
group
.
name
end
context
"on validation error"
do
before
do
fill_in
(
'project_path'
,
with:
'private-group-project'
)
choose
(
'Internal'
)
click_button
(
'Create project'
)
expect
(
page
).
to
have_css
'.project-edit-errors .alert.alert-danger'
end
it
"selects the group namespace"
do
namespace
=
find
(
"#project_namespace_id option[selected]"
)
expect
(
namespace
.
text
).
to
eq
group
.
name
end
end
end
end
context
'Import project options'
do
context
'Import project options'
do
before
do
before
do
visit
new_project_path
visit
new_project_path
...
...
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