diff --git a/app/services/imports/user_import_service.rb b/app/services/imports/user_import_service.rb index f5a730479..9ab8f6886 100644 --- a/app/services/imports/user_import_service.rb +++ b/app/services/imports/user_import_service.rb @@ -45,7 +45,7 @@ module Imports end def user_field_value(xml_document, field) - field_value(xml_document, "user", field) + field_value(xml_document, "user", field, { "user" => "dclg:user" }) end def role(field_value) diff --git a/spec/fixtures/imports/user/80d9b73aa1c88b6e5c36ee49be9050b923b4a1bb.xml b/spec/fixtures/imports/user/80d9b73aa1c88b6e5c36ee49be9050b923b4a1bb.xml new file mode 100644 index 000000000..8fd86a5b1 --- /dev/null +++ b/spec/fixtures/imports/user/80d9b73aa1c88b6e5c36ee49be9050b923b4a1bb.xml @@ -0,0 +1,19 @@ + + 80d9b73aa1c88b6e5c36ee49be9050b923b4a1bb + Jane Doe + 7c5bd5fb549c09a2c55d7cb90d7ba84927e64618 + 1158 1158 + true + Data Provider + + false + false + false + None + jane.doe@gov.uk + REDACTED + Jane Doe + 01111 000000 + false + 2021-09-28Z + \ No newline at end of file diff --git a/spec/services/imports/user_import_service_spec.rb b/spec/services/imports/user_import_service_spec.rb index b8a831dbc..ea3388169 100644 --- a/spec/services/imports/user_import_service_spec.rb +++ b/spec/services/imports/user_import_service_spec.rb @@ -107,6 +107,19 @@ RSpec.describe Imports::UserImportService do end end + context "when the user does not have namespace bindings" do + let(:old_user_id) { "80d9b73aa1c88b6e5c36ee49be9050b923b4a1bb" } + + it "imports them succesfully" do + FactoryBot.create(:organisation, old_org_id:) + import_service.create_users("user_directory") + + user = LegacyUser.find_by(old_user_id:)&.user + expect(user.name).to eq("Jane Doe") + expect(user.email).to eq("jane.doe@gov.uk") + end + end + context "when a user has already been imported with that email" do let!(:org) { FactoryBot.create(:organisation, old_org_id:) } let!(:user) { FactoryBot.create(:user, :data_provider, organisation: org, email: "john.doe@gov.uk") }