BigW Consortium Gitlab

Commit 7ebf22e0 by James Lopez

more refactoring and fixes - fixing spec as well

parent c46f3bcb
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
......
......@@ -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
......
......@@ -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
......
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment