Commit e51d5192 authored by James Lopez's avatar James Lopez

Merge branch 'georgekoltsov/remove-username-lookup-from-members-mapper' into 'master'

Remove Username lookup when resolving users in MembersMapper

See merge request gitlab-org/gitlab!24464
parents ca9af13f 5a592571
---
title: Remove username lookup when mapping users when importing projects using Project
Import/Export and rely on email only
merge_request: 24464
author:
type: changed
......@@ -26,7 +26,7 @@ Note the following:
and are deleted every 24 hours by a specific worker.
- Group members are exported as project members, as long as the user has
maintainer or admin access to the group where the exported project lives. An admin
in the import side is required to map the users, based on email or username.
in the import side is required to map the users, based on email.
Otherwise, a supplementary comment is left to mention the original author and
the MRs, notes, or issues will be owned by the importer.
- Project members with owner access will be imported as maintainers.
......
......@@ -439,7 +439,7 @@
"override":false,
"user":{
"id":2,
"email":"user_2@example.com",
"email":"user_2@gitlabexample.com",
"username":"user_2"
}
}
......
......@@ -70,8 +70,8 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
end
describe 'restoring design management data' do
let_it_be(:user) { create(:admin, username: 'user_1') }
let_it_be(:second_user) { create(:user, username: 'user_2' )}
let_it_be(:user) { create(:admin, email: 'user_1@gitlabexample.com') }
let_it_be(:second_user) { create(:user, email: 'user_2@gitlabexample.com') }
let_it_be(:project) do
create(:project, :builds_disabled, :issues_disabled,
{ name: 'project', path: 'project' })
......@@ -91,9 +91,9 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
describe 'restores issue associations correctly' do
let(:issue) { project.issues.offset(index).first }
where(:index, :design_filenames, :version_shas, :events, :author_usernames) do
0 | %w[chirrido3.jpg jonathan_richman.jpg mariavontrap.jpeg] | %w[27702d08f5ee021ae938737f84e8fe7c38599e85 9358d1bac8ff300d3d2597adaa2572a20f7f8703 e1a4a501bcb42f291f84e5d04c8f927821542fb6] | %w[creation creation creation modification modification deletion] | %w[user_1 user_1 user_2]
1 | ['1 (1).jpeg', '2099743.jpg', 'a screenshot (1).jpg', 'chirrido3.jpg'] | %w[73f871b4c8c1d65c62c460635e023179fb53abc4 8587e78ab6bda3bc820a9f014c3be4a21ad4fcc8 c9b5f067f3e892122a4b12b0a25a8089192f3ac8] | %w[creation creation creation creation modification] | %w[user_1 user_2 user_2]
where(:index, :design_filenames, :version_shas, :events, :author_emails) do
0 | %w[chirrido3.jpg jonathan_richman.jpg mariavontrap.jpeg] | %w[27702d08f5ee021ae938737f84e8fe7c38599e85 9358d1bac8ff300d3d2597adaa2572a20f7f8703 e1a4a501bcb42f291f84e5d04c8f927821542fb6] | %w[creation creation creation modification modification deletion] | %w[user_1@gitlabexample.com user_1@gitlabexample.com user_2@gitlabexample.com]
1 | ['1 (1).jpeg', '2099743.jpg', 'a screenshot (1).jpg', 'chirrido3.jpg'] | %w[73f871b4c8c1d65c62c460635e023179fb53abc4 8587e78ab6bda3bc820a9f014c3be4a21ad4fcc8 c9b5f067f3e892122a4b12b0a25a8089192f3ac8] | %w[creation creation creation creation modification] | %w[user_1@gitlabexample.com user_2@gitlabexample.com user_2@gitlabexample.com]
end
with_them do
......@@ -101,7 +101,7 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
expect(issue.designs.pluck(:filename)).to contain_exactly(*design_filenames)
expect(issue.design_versions.pluck(:sha)).to contain_exactly(*version_shas)
expect(issue.design_versions.flat_map(&:actions).map(&:event)).to contain_exactly(*events)
expect(issue.design_versions.map(&:author).map(&:username)).to contain_exactly(*author_usernames)
expect(issue.design_versions.map(&:author).map(&:email)).to contain_exactly(*author_emails)
end
end
end
......
......@@ -82,7 +82,7 @@ module Gitlab
end
def find_user_query(member)
user_arel[:email].eq(member['user']['email']).or(user_arel[:username].eq(member['user']['username']))
user_arel[:email].eq(member['user']['email'])
end
def user_arel
......
......@@ -2398,7 +2398,7 @@
"requested_at": null,
"user": {
"id": 16,
"email": "maritza_schoen@block.ca",
"email": "bernard_willms@gitlabexample.com",
"username": "bernard_willms"
}
},
......@@ -2418,7 +2418,7 @@
"requested_at": null,
"user": {
"id": 6,
"email": "shaina@koelpindenesik.com",
"email": "saul_will@gitlabexample.com",
"username": "saul_will"
}
},
......
......@@ -348,7 +348,7 @@
"override": false,
"user": {
"id": 206,
"email": "margaret.bergnaum@reynolds.us",
"email": "gwendolyn_robel@gitlabexample.com",
"username": "gwendolyn_robel"
}
},
......@@ -394,7 +394,7 @@
"override": false,
"user": {
"id": 1624,
"email": "nakesha.herzog@powlowski.com",
"email": "adriene.mcclure@gitlabexample.com",
"username": "adriene.mcclure"
}
},
......
......@@ -10,9 +10,9 @@ describe Gitlab::ImportExport::GroupTreeRestorer do
describe 'restore group tree' do
before(:context) do
# Using an admin for import, so we can check assignment of existing members
user = create(:admin, username: 'root')
create(:user, username: 'adriene.mcclure')
create(:user, username: 'gwendolyn_robel')
user = create(:admin, email: 'root@gitlabexample.com')
create(:user, email: 'adriene.mcclure@gitlabexample.com')
create(:user, email: 'gwendolyn_robel@gitlabexample.com')
RSpec::Mocks.with_temporary_scope do
@group = create(:group, name: 'group', path: 'group')
......@@ -56,7 +56,7 @@ describe Gitlab::ImportExport::GroupTreeRestorer do
end
it 'has group members' do
expect(@group.members.map(&:user).map(&:username)).to contain_exactly('root', 'adriene.mcclure', 'gwendolyn_robel')
expect(@group.members.map(&:user).map(&:email)).to contain_exactly('root@gitlabexample.com', 'adriene.mcclure@gitlabexample.com', 'gwendolyn_robel@gitlabexample.com')
end
end
end
......
......@@ -13,8 +13,8 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
# Using an admin for import, so we can check assignment of existing members
@user = create(:admin)
@existing_members = [
create(:user, username: 'bernard_willms'),
create(:user, username: 'saul_will')
create(:user, email: 'bernard_willms@gitlabexample.com'),
create(:user, email: 'saul_will@gitlabexample.com')
]
RSpec::Mocks.with_temporary_scope 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