From cbf22c332dac8e0ff933085ac83d39c80c4e500a Mon Sep 17 00:00:00 2001 From: Dominik Klein Date: Tue, 12 Apr 2022 07:23:29 +0200 Subject: [PATCH] Fixes #4051 - Freshdesk-Migration does not like no Companies / Organisations within the source. --- lib/sequencer/unit/import/freshdesk/contact/mapping.rb | 2 +- .../sequence/import/freshdesk/contact_spec.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/sequencer/unit/import/freshdesk/contact/mapping.rb b/lib/sequencer/unit/import/freshdesk/contact/mapping.rb index 58f25625b..4fdd2eeb0 100644 --- a/lib/sequencer/unit/import/freshdesk/contact/mapping.rb +++ b/lib/sequencer/unit/import/freshdesk/contact/mapping.rb @@ -29,7 +29,7 @@ class Sequencer private def organization_id - id_map['Organization'][resource['company_id']] + id_map.dig('Organization', resource['company_id']) end end end diff --git a/spec/lib/sequencer/sequence/import/freshdesk/contact_spec.rb b/spec/lib/sequencer/sequence/import/freshdesk/contact_spec.rb index fb5c6abcb..984758428 100644 --- a/spec/lib/sequencer/sequence/import/freshdesk/contact_spec.rb +++ b/spec/lib/sequencer/sequence/import/freshdesk/contact_spec.rb @@ -104,5 +104,15 @@ RSpec.describe ::Sequencer::Sequence::Import::Freshdesk::Contact, sequencer: :se expect(User.last).to have_attributes(imported_user) end end + + context 'without organizations' do + let(:id_map) do + {} + end + + it 'imports customer correctly (increased user count)' do + expect { process(process_payload) }.to change(User, :count).by(1) + end + end end end