integer_spec.rb 1.6 KB

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