checkbox_spec.rb 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. require 'rails_helper'
  2. RSpec.describe Import::Zendesk::ObjectAttribute::Checkbox do
  3. it 'imports boolean object attribute from checkbox 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: 'checkbox',
  14. )
  15. expected_structure = {
  16. object: 'Ticket',
  17. name: 'example_field',
  18. display: 'Example attribute',
  19. data_type: 'boolean',
  20. data_option: {
  21. null: false,
  22. note: 'Example attribute description',
  23. default: false,
  24. options: {
  25. true => 'yes',
  26. false => 'no'
  27. }
  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