Follow up: Fixed issue #519 - Import of articles without a content type fails.
This commit is contained in:
parent
0646b9dc25
commit
26b8ed32d3
2 changed files with 43 additions and 2 deletions
|
@ -36,8 +36,7 @@ module Import
|
|||
def import(article)
|
||||
create_or_update(map(article))
|
||||
|
||||
return if !article['Attachments']
|
||||
return if article['Attachments'].empty?
|
||||
return if article['Attachments'].blank?
|
||||
|
||||
Import::OTRS::Article::AttachmentFactory.import(
|
||||
attachments: article['Attachments'],
|
||||
|
@ -69,6 +68,14 @@ module Import
|
|||
end
|
||||
|
||||
def map(article)
|
||||
mapped = map_default(article)
|
||||
# if no content type is set make sure to remove it
|
||||
# so Zammad can set the default content type
|
||||
mapped.delete(:content_type) if mapped[:content_type].blank?
|
||||
mapped
|
||||
end
|
||||
|
||||
def map_default(article)
|
||||
{
|
||||
created_by_id: 1,
|
||||
updated_by_id: 1,
|
||||
|
|
|
@ -60,4 +60,38 @@ RSpec.describe Import::OTRS::Article do
|
|||
updates_with(zammad_structure)
|
||||
end
|
||||
end
|
||||
|
||||
context 'no content type' do
|
||||
|
||||
let(:object_structure) { load_article_json('no_content_type') }
|
||||
let(:zammad_structure) {
|
||||
{
|
||||
created_by_id: '1',
|
||||
updated_by_id: 1,
|
||||
ticket_id: '999',
|
||||
id: '999',
|
||||
body: "Welcome!\n\nThank you for installing OTRS.\n\nYou will find updates and patches at http://www.otrs.com/open-source/.\nOnline documentation is available at http://doc.otrs.org/.\nYou can also use our mailing lists http://lists.otrs.org/\nor our forums at http://forums.otrs.org/\n\nRegards,\n\nThe OTRS Project\n",
|
||||
from: 'OTRS Feedback <feedback@otrs.org>',
|
||||
to: 'Your OTRS System <otrs@localhost>',
|
||||
cc: nil,
|
||||
subject: 'Welcome to OTRS!',
|
||||
in_reply_to: nil,
|
||||
message_id: '<007@localhost>',
|
||||
references: nil,
|
||||
updated_at: '2014-06-24 09:32:14',
|
||||
created_at: '2010-08-02 14:00:00',
|
||||
type_id: 1,
|
||||
internal: false,
|
||||
sender_id: 2
|
||||
}
|
||||
}
|
||||
|
||||
it 'creates' do
|
||||
creates_with(zammad_structure)
|
||||
end
|
||||
|
||||
it 'updates' do
|
||||
updates_with(zammad_structure)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue