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
1bd4d7cc
Commit
1bd4d7cc
authored
Sep 18, 2019
by
Victor Zagorodny
Committed by
Stan Hu
Sep 18, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix broken development DB seeds for forks
parent
e3bd2bff
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
7 deletions
+27
-7
app/services/projects/fork_service.rb
app/services/projects/fork_service.rb
+6
-1
db/fixtures/development/24_forks.rb
db/fixtures/development/24_forks.rb
+7
-2
spec/services/projects/fork_service_spec.rb
spec/services/projects/fork_service_spec.rb
+14
-4
No files found.
app/services/projects/fork_service.rb
View file @
1bd4d7cc
...
...
@@ -51,7 +51,8 @@ module Projects
# been instantiated to avoid ActiveRecord trying to create it when
# initializing the project, as that would cause a foreign key constraint
# exception.
relations_block:
->
(
project
)
{
build_fork_network_member
(
project
)
}
relations_block:
->
(
project
)
{
build_fork_network_member
(
project
)
},
skip_disk_validation:
skip_disk_validation
}
if
@project
.
avatar
.
present?
&&
@project
.
avatar
.
image?
...
...
@@ -110,6 +111,10 @@ module Projects
@target_namespace
||=
@params
[
:namespace
]
||
current_user
.
namespace
end
def
skip_disk_validation
@skip_disk_validation
||=
@params
[
:skip_disk_validation
]
||
false
end
def
allowed_visibility_level
target_level
=
[
@project
.
visibility_level
,
target_namespace
.
visibility_level
].
min
...
...
db/fixtures/development/24_forks.rb
View file @
1bd4d7cc
...
...
@@ -6,11 +6,16 @@ Sidekiq::Testing.inline! do
source_project
=
Project
.
public_only
.
sample
##
# 0
4
_project.rb might not have created a public project because
# 0
3
_project.rb might not have created a public project because
# we use randomized approach (e.g. `Array#sample`).
return
unless
source_project
fork_project
=
Projects
::
ForkService
.
new
(
source_project
,
user
,
namespace:
user
.
namespace
).
execute
fork_project
=
Projects
::
ForkService
.
new
(
source_project
,
user
,
namespace:
user
.
namespace
,
skip_disk_validation:
true
).
execute
if
fork_project
.
valid?
print
'.'
...
...
spec/services/projects/fork_service_spec.rb
View file @
1bd4d7cc
...
...
@@ -119,6 +119,7 @@ describe Projects::ForkService do
context
'repository in legacy storage already exists'
do
let
(
:repository_storage
)
{
'default'
}
let
(
:repository_storage_path
)
{
Gitlab
.
config
.
repositories
.
storages
[
repository_storage
].
legacy_disk_path
}
let
(
:params
)
{
{
namespace:
@to_user
.
namespace
}
}
before
do
stub_application_setting
(
hashed_storage_enabled:
false
)
...
...
@@ -129,12 +130,21 @@ describe Projects::ForkService do
gitlab_shell
.
remove_repository
(
repository_storage
,
"
#{
@to_user
.
namespace
.
full_path
}
/
#{
@from_project
.
path
}
"
)
end
subject
{
fork_project
(
@from_project
,
@to_user
,
params
)
}
it
'does not allow creation'
do
to_project
=
fork_project
(
@from_project
,
@to_user
,
namespace:
@to_user
.
namespace
)
expect
(
subject
).
not_to
be_persisted
expect
(
subject
.
errors
.
messages
).
to
have_key
(
:base
)
expect
(
subject
.
errors
.
messages
[
:base
].
first
).
to
match
(
'There is already a repository with that name on disk'
)
end
expect
(
to_project
).
not_to
be_persisted
expect
(
to_project
.
errors
.
messages
).
to
have_key
(
:base
)
expect
(
to_project
.
errors
.
messages
[
:base
].
first
).
to
match
(
'There is already a repository with that name on disk'
)
context
'when repository disk validation is explicitly skipped'
do
let
(
:params
)
{
super
().
merge
(
skip_disk_validation:
true
)
}
it
'allows fork project creation'
do
expect
(
subject
).
to
be_persisted
expect
(
subject
.
errors
.
messages
).
to
be_empty
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