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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
075ee478
Commit
075ee478
authored
Aug 01, 2018
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix selection of existing project key by default
parent
aa5821e5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
6 deletions
+17
-6
app/helpers/namespaces_helper.rb
app/helpers/namespaces_helper.rb
+6
-5
spec/helpers/namespaces_helper_spec.rb
spec/helpers/namespaces_helper_spec.rb
+11
-1
No files found.
app/helpers/namespaces_helper.rb
View file @
075ee478
...
...
@@ -9,6 +9,7 @@ module NamespacesHelper
.
includes
(
:route
)
.
order
(
'routes.path'
)
users
=
[
current_user
.
namespace
]
selected_id
=
current_user
.
namespace
.
id
unless
extra_group
.
nil?
||
extra_group
.
is_a?
(
Group
)
extra_group
=
Group
.
find
(
extra_group
)
if
Namespace
.
find
(
extra_group
).
kind
==
'group'
...
...
@@ -23,11 +24,11 @@ module NamespacesHelper
end
if
Ability
.
allowed?
(
current_user
,
:read_group
,
extra_group
)
selected
=
extra_group
.
id
if
selected
==
:extra_group
# Assign the value to an invalid primary ID so that the select box works
extra_group
.
id
=
-
1
if
!
extra_group
.
persisted?
selected_id
=
extra_group
.
id
if
selected
==
:extra_group
groups
|=
[
extra_group
]
end
selected
||=
:current_user
end
options
=
[]
...
...
@@ -37,11 +38,11 @@ module NamespacesHelper
options
<<
options_for_group
(
users
,
display_path:
display_path
,
type:
'user'
)
if
selected
==
:current_user
&&
current_user
.
namespace
selected
=
current_user
.
namespace
.
id
selected
_id
=
current_user
.
namespace
.
id
end
end
grouped_options_for_select
(
options
,
selected
)
grouped_options_for_select
(
options
,
selected
_id
)
end
def
namespace_icon
(
namespace
,
size
=
40
)
...
...
spec/helpers/namespaces_helper_spec.rb
View file @
075ee478
...
...
@@ -40,7 +40,7 @@ describe NamespacesHelper do
expect
(
options
).
to
include
(
admin_group
.
name
)
end
it
'selects ex
tra_
group'
do
it
'selects ex
isting
group'
do
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
admin
)
options
=
helper
.
namespaces_options
(
:extra_group
,
display_path:
true
,
extra_group:
user_group
)
...
...
@@ -49,6 +49,16 @@ describe NamespacesHelper do
expect
(
options
).
to
include
(
admin_group
.
name
)
end
it
'selects the new group by default'
do
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
user
)
options
=
helper
.
namespaces_options
(
:extra_group
,
display_path:
true
,
extra_group:
build
(
:group
,
name:
'new-group'
))
expect
(
options
).
to
include
(
user_group
.
name
)
expect
(
options
).
not_to
include
(
admin_group
.
name
)
expect
(
options
).
to
include
(
"selected=
\"
selected
\"
value=
\"
-1
\"
"
)
end
it
'falls back to current user selection'
do
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
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