date_spec.rb 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. require 'rails_helper'
  2. # required due to some of rails autoloading issues
  3. require 'import/zendesk/object_attribute/date'
  4. RSpec.describe Import::Zendesk::ObjectAttribute::Date do
  5. it 'imports date object attribute from date 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: 'date',
  16. )
  17. expected_structure = {
  18. object: 'Ticket',
  19. name: 'example_field',
  20. display: 'Example attribute',
  21. data_type: 'date',
  22. data_option: {
  23. null: false,
  24. note: 'Example attribute description',
  25. future: true,
  26. past: true,
  27. diff: 0,
  28. },
  29. editable: true,
  30. active: true,
  31. screens: {
  32. edit: {
  33. Customer: {
  34. shown: true,
  35. null: false
  36. },
  37. view: {
  38. '-all-' => {
  39. shown: true
  40. }
  41. }
  42. }
  43. },
  44. position: 12,
  45. created_by_id: 1,
  46. updated_by_id: 1
  47. }
  48. expect(ObjectManager::Attribute).to receive(:add).with(expected_structure)
  49. expect(ObjectManager::Attribute).to receive(:migration_execute)
  50. described_class.new('Ticket', 'example_field', attribute)
  51. end
  52. end