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
7ebf22e0
Commit
7ebf22e0
authored
Apr 29, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more refactoring and fixes - fixing spec as well
parent
c46f3bcb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
11 deletions
+40
-11
lib/gitlab/import_export/project_tree_restorer.rb
lib/gitlab/import_export/project_tree_restorer.rb
+4
-6
lib/gitlab/import_export/repo_bundler.rb
lib/gitlab/import_export/repo_bundler.rb
+1
-0
lib/gitlab/import_export/repo_restorer.rb
lib/gitlab/import_export/repo_restorer.rb
+3
-2
spec/features/projects/import_export/import_file_spec.rb
spec/features/projects/import_export/import_file_spec.rb
+32
-3
No files found.
lib/gitlab/import_export/project_tree_restorer.rb
View file @
7ebf22e0
module
Gitlab
module
ImportExport
class
ProjectTreeRestorer
attr_reader
:project
def
initialize
(
path
:,
user
:,
project_path
:)
@path
=
File
.
join
(
path
,
'project.json'
)
...
...
@@ -16,6 +15,10 @@ module Gitlab
create_relations
end
def
project
@project
||=
create_project
end
private
def
members_map
...
...
@@ -41,17 +44,12 @@ module Gitlab
Gitlab
::
ImportExport
::
ImportExportReader
.
tree
.
reject
{
|
model
|
model
.
is_a?
(
Hash
)
&&
model
[
:project_members
]
}
end
def
project
@project
||=
create_project
end
def
create_project
project_params
=
@tree_hash
.
reject
{
|
_key
,
value
|
value
.
is_a?
(
Array
)
}
project
=
Gitlab
::
ImportExport
::
ProjectFactory
.
create
(
project_params:
project_params
,
user:
@user
)
project
.
path
=
@project_path
project
.
save
project
.
import_start
project
end
...
...
lib/gitlab/import_export/repo_bundler.rb
View file @
7ebf22e0
...
...
@@ -26,6 +26,7 @@ module Gitlab
false
end
# TODO remove magic keyword and move it to a shared config
def
project_filename
"project.bundle"
end
...
...
lib/gitlab/import_export/repo_restorer.rb
View file @
7ebf22e0
...
...
@@ -3,9 +3,10 @@ module Gitlab
class
RepoRestorer
include
Gitlab
::
ImportExport
::
CommandLineUtil
def
initialize
(
project:
,
path
:
,
bundler_file:
)
def
initialize
(
project:
,
path:
)
@project
=
project
@path
=
File
.
join
(
path
,
bundler_file
)
# TODO remove magic keyword and move it to a shared config
@path
=
File
.
join
(
path
,
'project.bundle'
)
end
def
restore
...
...
spec/features/projects/import_export/import_file_spec.rb
View file @
7ebf22e0
...
...
@@ -3,8 +3,10 @@ require 'spec_helper'
feature
'project import'
,
feature:
true
,
js:
true
do
include
Select2Helper
let
(
:user
)
{
create
(
:
user
)
}
let
(
:user
)
{
create
(
:
admin
)
}
let!
(
:namespace
)
{
create
(
:namespace
,
name:
"asd"
,
owner:
user
)
}
let
(
:file
)
{
File
.
join
(
Rails
.
root
,
'spec'
,
'features'
,
'projects'
,
'import_export'
,
'test_project_export.tar.gz'
)
}
background
do
login_as
(
user
)
end
...
...
@@ -12,11 +14,38 @@ feature 'project import', feature: true, js: true do
scenario
'user imports an exported project successfully'
do
visit
new_project_path
select2
(
'
asd
'
,
from:
'#project_namespace_id'
)
select2
(
'
2
'
,
from:
'#project_namespace_id'
)
fill_in
:project_path
,
with
:'test-project-path'
,
visible:
true
click_link
'GitLab project'
expect
(
page
).
to
have_content
(
'GitLab export file'
)
expect
(
URI
.
parse
(
current_url
).
query
).
to
eq
(
'namespace_id=asd&path=test-project-path'
)
expect
(
URI
.
parse
(
current_url
).
query
).
to
eq
(
'namespace_id=2&path=test-project-path'
)
attach_file
(
'file'
,
file
)
#TODO check timings
sleep
1
click_on
'Continue to the next step'
sleep
1
end
def
drop_in_dropzone
(
file_path
)
# Generate a fake input selector
page
.
execute_script
<<-
JS
var fakeFileInput = window.$('<input/>').attr(
{id: 'fakeFileInput', type: 'file'}
).appendTo('body');
JS
# Attach the file to the fake input selector with Capybara
attach_file
(
"fakeFileInput"
,
file_path
)
# Add the file to a fileList array and trigger the fake drop event
page
.
execute_script
<<-
JS
var fileList = [$('#fakeFileInput')[0].files[0]];
var e = jQuery.Event('drop', { dataTransfer : { files : fileList } });
$('.div-dropzone')[0].dropzone.listeners[0].events.drop(e);
JS
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