date_spec.rb 1.6 KB

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