From 083d7b6410b063b643333cb6f3623e32a77654af Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Tue, 29 Nov 2016 10:05:49 +0100 Subject: [PATCH] Working on issue #368 - OTRS tickets with empty title fail import. --- lib/import/otrs/ticket.rb | 11 ++++++++++- spec/import/otrs/ticket_spec.rb | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/lib/import/otrs/ticket.rb b/lib/import/otrs/ticket.rb index 5e2841d0e..605b89f51 100644 --- a/lib/import/otrs/ticket.rb +++ b/lib/import/otrs/ticket.rb @@ -66,8 +66,17 @@ module Import end def map(ticket) + ensure_map(default_map(ticket)) + end + + def ensure_map(mapped) + return mapped if mapped[:title] + mapped[:title] = '**EMPTY**' + mapped + end + + def default_map(ticket) { - title: '', owner_id: owner_id(ticket), customer_id: customer_id(ticket), created_by_id: 1, diff --git a/spec/import/otrs/ticket_spec.rb b/spec/import/otrs/ticket_spec.rb index 66a940e8a..0c4a4612b 100644 --- a/spec/import/otrs/ticket_spec.rb +++ b/spec/import/otrs/ticket_spec.rb @@ -65,4 +65,36 @@ RSpec.describe Import::OTRS::Ticket do updates_with(zammad_structure) end end + + context 'no title' do + + let(:object_structure) { load_ticket_json('no_title') } + let(:zammad_structure) { + { + title: '**EMPTY**', + owner_id: 1, + customer_id: 1, + created_by_id: '3', + updated_by_id: 1, + updated_at: '2014-11-21 00:21:08', + created_at: '2014-11-21 00:17:40', + number: '20141121305000012', + group_id: '1', + state_id: '2', + priority_id: '3', + id: '730', + close_at: '2014-11-21 00:21:08' + } + } + + it 'creates' do + import_backend_expectations + creates_with(zammad_structure) + end + + it 'updates' do + import_backend_expectations + updates_with(zammad_structure) + end + end end