Commit 97c3aff1 authored by James Lopez's avatar James Lopez

refactored import stuff, moved to lib

parent adbcccb4
......@@ -8,7 +8,7 @@ module Projects
private
def restore_project_tree
Projects::ImportExport::ProjectTreeRestorer.new(path: @import_path).restore
Gitlab::ImportExport::ProjectTreeRestorer.new(path: @import_path).restore
end
def restore_repo
......
module Projects
module Gitlab
module ImportExport
module ProjectFactory
extend self
......
module Projects
module Gitlab
module ImportExport
class ProjectTreeRestorer
attr_reader :project
......@@ -18,7 +18,7 @@ module Projects
private
def members_map
@members ||= Projects::ImportExport::MembersMapper.map(
@members ||= Gitlab::ImportExport::MembersMapper.map(
exported_members: @project_members, user: @user, project_id: project.id)
end
......@@ -37,7 +37,7 @@ module Projects
end
def default_relation_list
Projects::ImportExport::ImportExportReader.tree.reject { |model| model.is_a?(Hash) && model[:project_members] }
Gitlab::ImportExport::ImportExportReader.tree.reject { |model| model.is_a?(Hash) && model[:project_members] }
end
def project
......@@ -46,7 +46,7 @@ module Projects
def create_project
project_params = @tree_hash.reject { |_key, value| value.is_a?(Array) }
project = Projects::ImportExport::ProjectFactory.create(
project = Gitlab::ImportExport::ProjectFactory.create(
project_params: project_params, user: @user)
project.save
project
......@@ -79,7 +79,7 @@ module Projects
end
def relation_from_factory(relation, relation_hash)
Projects::ImportExport::RelationFactory.create(
Gitlab::ImportExport::RelationFactory.create(
relation_sym: relation, relation_hash: relation_hash.merge('project_id' => project.id), members_map: members_map)
end
end
......
module Projects
module Gitlab
module ImportExport
module RelationFactory
extend self
......
require 'spec_helper'
describe Projects::ImportExport::MembersMapper, services: true do
describe Gitlab::ImportExport::MembersMapper, services: true do
describe :map do
let(:user) { create(:user) }
......@@ -31,7 +31,7 @@ describe Projects::ImportExport::MembersMapper, services: true do
end
let(:members_mapper) do
Projects::ImportExport::MembersMapper.new(
Gitlab::ImportExport::MembersMapper.new(
exported_members: exported_members, user: user, project_id: project.id)
end
......
require 'spec_helper'
describe Projects::ImportExport::ProjectTreeRestorer, services: true do
describe Gitlab::ImportExport::ProjectTreeRestorer, services: true do
describe :restore do
let(:user) { create(:user) }
let(:project_tree_restorer) { Projects::ImportExport::ProjectTreeRestorer.new(path: "fixtures/import_export/project.json", user: user) }
let(:project_tree_restorer) { Gitlab::ImportExport::ProjectTreeRestorer.new(path: "fixtures/import_export/project.json", user: user) }
context 'JSON' do
let(:restored_project_json) do
......
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