Fixed issue #565 - Unsupported DynamicField type fields cause import to abort.

This commit is contained in:
Thorsten Eckel 2017-01-13 10:59:14 +01:00
parent 6fab80adee
commit 2f955f4087
3 changed files with 26 additions and 3 deletions

View file

@ -8,9 +8,10 @@ module Import
extend self
def skip?(record, *_args)
return true if !importable?(record)
return true if skip_field?(record['Name'])
false
return false if importable?(record)
@skip_fields.push(record['Name'])
true
end
def backend_class(record, *_args)
@ -45,7 +46,8 @@ module Import
end
def skip_fields
%w(ProcessManagementProcessID ProcessManagementActivityID ZammadMigratorChanged ZammadMigratorChangedOld)
return @skip_fields if @skip_fields
@skip_fields = %w(ProcessManagementProcessID ProcessManagementActivityID ZammadMigratorChanged ZammadMigratorChangedOld)
end
end
end

View file

@ -0,0 +1,16 @@
{
"ID": "8",
"ChangeTime": "2014-09-12 09:31:58",
"InternalField": "0",
"ValidID": "1",
"CreateTime": "2014-06-19 12:11:23",
"Label": "Master Slave",
"FieldOrder": "8",
"Config": {
"DefaultValue": "",
"Link": ""
},
"FieldType": "MasterSlave",
"Name": "MasterSlave",
"ObjectType": "Ticket"
}

View file

@ -12,6 +12,11 @@ RSpec.describe Import::OTRS::DynamicFieldFactory do
expect(described_class).to respond_to('skip_field?')
end
it 'skips fields that have unsupported types' do
described_class.import([load_dynamic_field_json('unsupported/master_slave')])
expect(described_class.skip_field?('MasterSlave')).to be true
end
it 'imports OTRS DynamicFields' do
expect(Import::OTRS::DynamicField::Text).to receive(:new)
start_import_test