2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2016-12-19 08:59:54 +00:00
|
|
|
require 'rails_helper'
|
2018-12-14 01:59:19 +00:00
|
|
|
require 'lib/import/zendesk/object_attribute/base_examples'
|
2016-12-19 08:59:54 +00:00
|
|
|
|
|
|
|
RSpec.describe Import::Zendesk::ObjectAttribute::Dropdown do
|
2018-12-14 01:59:19 +00:00
|
|
|
it_behaves_like Import::Zendesk::ObjectAttribute::Base
|
2016-12-19 08:59:54 +00:00
|
|
|
|
|
|
|
it 'imports select object attribute from dropdown object field' do
|
|
|
|
|
|
|
|
attribute = double(
|
|
|
|
title: 'Example attribute',
|
|
|
|
description: 'Example attribute description',
|
|
|
|
removable: false,
|
|
|
|
active: true,
|
|
|
|
position: 12,
|
|
|
|
visible_in_portal: true,
|
|
|
|
required_in_portal: true,
|
|
|
|
required: true,
|
|
|
|
type: 'dropdown',
|
|
|
|
custom_field_options: [
|
|
|
|
{
|
|
|
|
'id' => 1,
|
|
|
|
'value' => 'Key 1',
|
|
|
|
'name' => 'Value 1'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'id' => 2,
|
|
|
|
'value' => 'Key 2',
|
|
|
|
'name' => 'Value 2'
|
|
|
|
},
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
expected_structure = {
|
2018-12-19 17:31:51 +00:00
|
|
|
object: 'Ticket',
|
|
|
|
name: 'example_field',
|
|
|
|
display: 'Example attribute',
|
|
|
|
data_type: 'select',
|
|
|
|
data_option: {
|
|
|
|
null: false,
|
|
|
|
note: 'Example attribute description',
|
2016-12-19 08:59:54 +00:00
|
|
|
default: '',
|
|
|
|
options: {
|
|
|
|
'Key 1' => 'Value 1',
|
|
|
|
'Key 2' => 'Value 2'
|
|
|
|
},
|
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
editable: true,
|
|
|
|
active: true,
|
|
|
|
screens: {
|
2016-12-19 08:59:54 +00:00
|
|
|
edit: {
|
|
|
|
Customer: {
|
|
|
|
shown: true,
|
2018-12-19 17:31:51 +00:00
|
|
|
null: false
|
2016-12-19 08:59:54 +00:00
|
|
|
},
|
2018-12-19 17:31:51 +00:00
|
|
|
view: {
|
2016-12-19 08:59:54 +00:00
|
|
|
'-all-' => {
|
|
|
|
shown: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
position: 12,
|
|
|
|
created_by_id: 1,
|
|
|
|
updated_by_id: 1
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(ObjectManager::Attribute).to receive(:add).with(expected_structure)
|
|
|
|
expect(ObjectManager::Attribute).to receive(:migration_execute)
|
|
|
|
|
2019-06-28 11:38:49 +00:00
|
|
|
described_class.new('Ticket', 'example_field', attribute)
|
2016-12-19 08:59:54 +00:00
|
|
|
end
|
|
|
|
end
|