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

refactored import stuff, moved to lib

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