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::Text 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 input object attribute from text 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: 'text',
|
|
|
|
)
|
|
|
|
|
|
|
|
expected_structure = {
|
|
|
|
object: 'Ticket',
|
|
|
|
name: 'example_field',
|
|
|
|
display: 'Example attribute',
|
|
|
|
data_type: 'input',
|
|
|
|
data_option: {
|
|
|
|
null: false,
|
|
|
|
note: 'Example attribute description',
|
|
|
|
type: 'text',
|
|
|
|
maxlength: 255,
|
|
|
|
},
|
|
|
|
editable: true,
|
|
|
|
active: true,
|
|
|
|
screens: {
|
|
|
|
edit: {
|
|
|
|
Customer: {
|
|
|
|
shown: true,
|
|
|
|
null: false
|
|
|
|
},
|
|
|
|
view: {
|
|
|
|
'-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)
|
|
|
|
|
|
|
|
described_class.new('Ticket', 'example_field', attribute)
|
|
|
|
end
|
|
|
|
end
|