text_spec.rb 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. require 'rails_helper'
  2. RSpec.describe Import::Zendesk::ObjectAttribute::Text do
  3. it 'imports input object attribute from text object field' do
  4. attribute = double(
  5. title: 'Example attribute',
  6. description: 'Example attribute description',
  7. removable: false,
  8. active: true,
  9. position: 12,
  10. visible_in_portal: true,
  11. required_in_portal: true,
  12. required: true,
  13. type: 'text',
  14. )
  15. expected_structure = {
  16. object: 'Ticket',
  17. name: 'example_field',
  18. display: 'Example attribute',
  19. data_type: 'input',
  20. data_option: {
  21. null: false,
  22. note: 'Example attribute description',
  23. type: 'text',
  24. maxlength: 255,
  25. },
  26. editable: true,
  27. active: true,
  28. screens: {
  29. edit: {
  30. Customer: {
  31. shown: true,
  32. null: false
  33. },
  34. view: {
  35. '-all-' => {
  36. shown: true
  37. }
  38. }
  39. }
  40. },
  41. position: 12,
  42. created_by_id: 1,
  43. updated_by_id: 1
  44. }
  45. expect(ObjectManager::Attribute).to receive(:add).with(expected_structure)
  46. expect(ObjectManager::Attribute).to receive(:migration_execute)
  47. described_class.new('Ticket', 'example_field', attribute)
  48. end
  49. end