diff options
author | James Lopez <james@jameslopez.es> | 2017-01-18 15:46:54 +0100 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2017-01-18 15:46:54 +0100 |
commit | b3bb8dc46faf448d02e917586e7666143d7ab968 (patch) | |
tree | 4670555012caacdfe87f53b0fe0f05b3e61c0e8b /spec/lib | |
parent | 35442766cf1041d2bb100ff73f58f92347649027 (diff) | |
download | gitlab-ce-b3bb8dc46faf448d02e917586e7666143d7ab968.tar.gz |
added spec replicating the problem
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/import_export/members_mapper_spec.rb | 3 | ||||
-rw-r--r-- | spec/lib/gitlab/import_export/relation_factory_spec.rb | 58 |
2 files changed, 59 insertions, 2 deletions
diff --git a/spec/lib/gitlab/import_export/members_mapper_spec.rb b/spec/lib/gitlab/import_export/members_mapper_spec.rb index 95666a7cc02..af3a0ab2b45 100644 --- a/spec/lib/gitlab/import_export/members_mapper_spec.rb +++ b/spec/lib/gitlab/import_export/members_mapper_spec.rb @@ -75,8 +75,9 @@ describe Gitlab::ImportExport::MembersMapper, services: true do expect(user2.authorized_project?(project)).to be true end - context 'user is not admin' do + context 'user is not an admin' do let(:user) { create(:user, authorized_projects_populated: true) } + it 'does not map a project member' do expect(members_mapper.map[exported_user_id]).to eq(user.id) end diff --git a/spec/lib/gitlab/import_export/relation_factory_spec.rb b/spec/lib/gitlab/import_export/relation_factory_spec.rb index 3aa492a8ab1..4604e88b295 100644 --- a/spec/lib/gitlab/import_export/relation_factory_spec.rb +++ b/spec/lib/gitlab/import_export/relation_factory_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Gitlab::ImportExport::RelationFactory, lib: true do let(:project) { create(:empty_project) } let(:members_mapper) { double('members_mapper').as_null_object } - let(:user) { create(:user) } + let(:user) { create(:admin) } let(:created_object) do described_class.create(relation_sym: relation_sym, relation_hash: relation_hash, @@ -122,4 +122,60 @@ describe Gitlab::ImportExport::RelationFactory, lib: true do expect(created_object.values).not_to include(99) end end + + context 'Notes user references' do + let(:relation_sym) { :notes } + let(:new_user) { create(:user) } + let(:exported_member) do + { + "id" => 999, + "access_level" => 30, + "source_id" => 1, + "source_type" => "Project", + "user_id" => 3, + "notification_level" => 3, + "created_at" => "2016-11-18T09:29:42.634Z", + "updated_at" => "2016-11-18T09:29:42.634Z", + "user" => { + "id" => new_user.id, + "email" => new_user.email, + "username" => new_user.username + } + } + end + + let(:relation_hash) do + { + "id" => 4947, + "note" => "merged", + "noteable_type" => "MergeRequest", + "author_id" => 999, + "created_at" => "2016-11-18T09:29:42.634Z", + "updated_at" => "2016-11-18T09:29:42.634Z", + "project_id" => 1, + "attachment" => { + "url" => nil + }, + "noteable_id" => 377, + "system" => true, + "author" => { + "name" => "Administrator" + }, + "events" => [ + + ] + } + end + + let(:members_mapper) do + Gitlab::ImportExport::MembersMapper.new( + exported_members: [exported_member], + user: user, + project: project) + end + + it 'maps the right author to the imported note' do + expect(created_object.author).to eq(new_user) + end + end end |