Commit 49cdb778 authored by James Lopez's avatar James Lopez

few fixes to import specs and code

parent 4290e9c8
...@@ -14,7 +14,8 @@ module Gitlab ...@@ -14,7 +14,8 @@ module Gitlab
@tree_hash = ActiveSupport::JSON.decode(json) @tree_hash = ActiveSupport::JSON.decode(json)
@project_members = @tree_hash.delete('project_members') @project_members = @tree_hash.delete('project_members')
create_relations create_relations
rescue rescue => e
# TODO: handle errors better, move them to a shared thing
false false
end end
...@@ -83,7 +84,7 @@ module Gitlab ...@@ -83,7 +84,7 @@ module Gitlab
def relation_from_factory(relation, relation_hash) def relation_from_factory(relation, relation_hash)
Gitlab::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.to_sym, relation_hash: relation_hash.merge('project_id' => project.id), members_map: members_map)
end end
end end
end end
......
require 'spec_helper' require 'spec_helper'
describe Gitlab::ImportExport::MembersMapper, services: true do describe Gitlab::ImportExport::MembersMapper, services: true do
describe :map do describe 'map members' do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project, :public, name: 'searchable_project') } let(:project) { create(:project, :public, name: 'searchable_project') }
...@@ -31,7 +31,7 @@ describe Gitlab::ImportExport::MembersMapper, services: true do ...@@ -31,7 +31,7 @@ describe Gitlab::ImportExport::MembersMapper, services: true do
end end
let(:members_mapper) do let(:members_mapper) do
Gitlab::ImportExport::MembersMapper.new( described_class.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 Gitlab::ImportExport::ProjectTreeRestorer, services: true do describe Gitlab::ImportExport::ProjectTreeRestorer, services: true do
describe :restore do describe 'restore project tree' do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:namespace) { create(:namespace, owner: user) } let(:namespace) { create(:namespace, owner: user) }
let(:project_tree_restorer) { Gitlab::ImportExport::ProjectTreeRestorer.new(path: "lib/gitlab/import_export/", user: user, project_path: 'project', namespace_id: namespace.id) } let(:project_tree_restorer) { described_class.new(path: Rails.root.join("spec/lib/gitlab/import_export/"), user: user, project_path: 'project', namespace_id: namespace.id) }
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