integer_spec.rb 1.5 KB

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