From adf8babab55e4825d7a6d2c58b155bd608c5931a Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Sun, 14 May 2017 18:33:30 +0200 Subject: [PATCH] Fllow up: Fixed issue #893 - OTRS Importer problem with CAPITAL letters in email addresses. --- lib/import/otrs/customer_user.rb | 1 + lib/import/otrs/user.rb | 6 ++++ spec/lib/import/otrs/customer_user_spec.rb | 37 ++++++++++++++++++++++ spec/lib/import/otrs/user_spec.rb | 33 +++++++++++++++++++ 4 files changed, 77 insertions(+) diff --git a/lib/import/otrs/customer_user.rb b/lib/import/otrs/customer_user.rb index cef25f1a0..47b9b5e47 100644 --- a/lib/import/otrs/customer_user.rb +++ b/lib/import/otrs/customer_user.rb @@ -67,6 +67,7 @@ module Import mapped = map_default(customer) mapped[:created_at] ||= DateTime.current mapped[:updated_at] ||= DateTime.current + mapped[:email].downcase! mapped end diff --git a/lib/import/otrs/user.rb b/lib/import/otrs/user.rb index 384d43f1f..19291eb1c 100644 --- a/lib/import/otrs/user.rb +++ b/lib/import/otrs/user.rb @@ -66,6 +66,12 @@ module Import end def map(user) + mapped = map_default(user) + mapped[:email].downcase! + mapped + end + + def map_default(user) { created_by_id: 1, updated_by_id: 1, diff --git a/spec/lib/import/otrs/customer_user_spec.rb b/spec/lib/import/otrs/customer_user_spec.rb index 7a69f1430..086540800 100644 --- a/spec/lib/import/otrs/customer_user_spec.rb +++ b/spec/lib/import/otrs/customer_user_spec.rb @@ -118,4 +118,41 @@ RSpec.describe Import::OTRS::CustomerUser do updates_with(zammad_structure) end end + + context 'regular user' do + + let(:object_structure) { load_customer_json('capital_email') } + let(:zammad_structure) { + { + created_by_id: '1', + updated_by_id: '1', + active: true, + source: 'OTRS Import', + organization_id: 1337, + role_ids: [3], + updated_at: '2014-06-07 02:31:31', + created_at: '2014-06-07 02:31:31', + note: '', + email: 'qa100@t-online.de', + firstname: 'test669673', + lastname: 'test669673', + login: 'test669673', + password: 'f8be19af2f25837a31eff9131b0e47a5173290652c04a48b49b86474d48825ee', + phone: nil, + fax: nil, + mobile: nil, + street: nil, + zip: nil, + city: nil, + country: nil + }} + + it 'creates' do + creates_with(zammad_structure) + end + + it 'updates' do + updates_with(zammad_structure) + end + end end diff --git a/spec/lib/import/otrs/user_spec.rb b/spec/lib/import/otrs/user_spec.rb index 60b1d9d90..3802b844f 100644 --- a/spec/lib/import/otrs/user_spec.rb +++ b/spec/lib/import/otrs/user_spec.rb @@ -134,4 +134,37 @@ RSpec.describe Import::OTRS::User do updates_with(zammad_structure) end end + + context 'capital email' do + + let(:object_structure) { load_user_json('capital_email') } + let(:zammad_structure) { + { + created_by_id: 1, + updated_by_id: 1, + active: true, + source: 'OTRS Import', + role_ids: [2, 1], + group_ids: ['1'], + password: '{sha2}9faaba2ab242a99bbb6992e9424386375f6757c17e6484ae570f39d9cad9f28ea', + updated_at: '2014-04-28 10:53:18', + created_at: '2014-04-28 10:53:18', + id: '1', + email: 'root@localhost', + firstname: 'Admin', + lastname: 'OTRS', + login: 'root@localhost' + } + } + + it 'creates' do + prepare_expectations + creates_with(zammad_structure) + end + + it 'updates' do + prepare_expectations + updates_with(zammad_structure) + end + end end