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
11f46b45
Commit
11f46b45
authored
Apr 13, 2016
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Setup visibility level for project when transfering for a group
parent
f026e53c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
4 deletions
+41
-4
app/services/projects/transfer_service.rb
app/services/projects/transfer_service.rb
+17
-4
app/views/projects/edit.html.haml
app/views/projects/edit.html.haml
+1
-0
spec/services/projects/transfer_service_spec.rb
spec/services/projects/transfer_service_spec.rb
+23
-0
No files found.
app/services/projects/transfer_service.rb
View file @
11f46b45
...
@@ -34,9 +34,12 @@ module Projects
...
@@ -34,9 +34,12 @@ module Projects
raise
TransferError
.
new
(
"Project with same path in target namespace already exists"
)
raise
TransferError
.
new
(
"Project with same path in target namespace already exists"
)
end
end
# Apply new namespace id
# Apply new namespace id and visibility level
project
.
namespace
=
new_namespace
project
.
tap
do
|
p
|
project
.
save!
p
.
namespace
=
new_namespace
setup_visibility_level
(
p
,
new_namespace
)
p
.
save!
end
# Notifications
# Notifications
project
.
send_move_instructions
(
old_path
)
project
.
send_move_instructions
(
old_path
)
...
@@ -68,5 +71,15 @@ module Projects
...
@@ -68,5 +71,15 @@ module Projects
namespace
.
id
!=
project
.
namespace_id
&&
namespace
.
id
!=
project
.
namespace_id
&&
current_user
.
can?
(
:create_projects
,
namespace
)
current_user
.
can?
(
:create_projects
,
namespace
)
end
end
private
def
setup_visibility_level
(
project
,
new_namespace
)
return
unless
new_namespace
.
is_a?
(
Group
)
if
project
.
visibility_level
>
new_namespace
.
visibility_level
project
.
visibility_level
=
new_namespace
.
visibility_level
end
end
end
end
end
end
app/views/projects/edit.html.haml
View file @
11f46b45
...
@@ -210,6 +210,7 @@
...
@@ -210,6 +210,7 @@
%li
Be careful. Changing the project's namespace can have unintended side effects.
%li
Be careful. Changing the project's namespace can have unintended side effects.
%li
You can only transfer the project to namespaces you manage.
%li
You can only transfer the project to namespaces you manage.
%li
You will need to update your local repositories to point to the new location.
%li
You will need to update your local repositories to point to the new location.
%li
Project visibility level will be changed to match namespace rules when transfering to a group.
.form-actions
.form-actions
=
f
.
submit
'Transfer project'
,
class:
"btn btn-remove js-confirm-danger"
,
data:
{
"confirm-danger-message"
=>
transfer_project_message
(
@project
)
}
=
f
.
submit
'Transfer project'
,
class:
"btn btn-remove js-confirm-danger"
,
data:
{
"confirm-danger-message"
=>
transfer_project_message
(
@project
)
}
-
else
-
else
...
...
spec/services/projects/transfer_service_spec.rb
View file @
11f46b45
...
@@ -38,4 +38,27 @@ describe Projects::TransferService, services: true do
...
@@ -38,4 +38,27 @@ describe Projects::TransferService, services: true do
def
transfer_project
(
project
,
user
,
new_namespace
)
def
transfer_project
(
project
,
user
,
new_namespace
)
Projects
::
TransferService
.
new
(
project
,
user
).
execute
(
new_namespace
)
Projects
::
TransferService
.
new
(
project
,
user
).
execute
(
new_namespace
)
end
end
context
'visibility level'
do
let
(
:internal_group
)
{
create
(
:group
,
:internal
)
}
before
{
internal_group
.
add_owner
(
user
)
}
context
'when namespace visibility level < project visibility level'
do
let
(
:public_project
)
{
create
(
:project
,
:public
,
namespace:
user
.
namespace
)
}
before
{
transfer_project
(
public_project
,
user
,
internal_group
)
}
it
{
expect
(
public_project
.
visibility_level
).
to
eq
(
internal_group
.
visibility_level
)
}
end
context
'when namespace visibility level > project visibility level'
do
let
(
:private_project
)
{
create
(
:project
,
:private
,
namespace:
user
.
namespace
)
}
before
{
transfer_project
(
private_project
,
user
,
internal_group
)
}
it
{
expect
(
private_project
.
visibility_level
).
to
eq
(
Gitlab
::
VisibilityLevel
::
PRIVATE
)
}
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