case_field_spec.rb 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. require 'lib/sequencer/sequence/import/kayako/examples/object_custom_fields_examples'
  4. RSpec.describe Sequencer::Sequence::Import::Kayako::CaseField, sequencer: :sequence do
  5. context 'when trying to import ticket fields from Kayako', db_strategy: :reset do
  6. let(:imported_type_options) do
  7. {
  8. 'Question' => 'Question',
  9. 'Task' => 'Task',
  10. 'Problem' => 'Problem',
  11. 'Incident' => 'Incident',
  12. }
  13. end
  14. include_examples 'Object custom fields', klass: Ticket
  15. context 'when importing system fields' do
  16. let(:resource) do
  17. {
  18. 'id' => 80_000_387_409,
  19. 'fielduuid' => 'cad5295c-495a-4605-8eda-861d4a19d6f2',
  20. 'title' => 'Type',
  21. 'type' => 'TYPE',
  22. 'key' => 'type',
  23. 'is_required_for_agents' => false,
  24. 'is_required_on_resolution' => false,
  25. 'is_visible_to_customers' => false,
  26. 'is_customer_editable' => false,
  27. 'is_required_for_customers' => false,
  28. 'regular_expression' => nil,
  29. 'sort_order' => 5,
  30. 'is_enabled' => true,
  31. 'is_system' => true,
  32. 'options' => [],
  33. 'created_at' => '2021-08-12T11:48:51+00:00',
  34. 'updated_at' => '2021-08-12T11:48:51+00:00',
  35. }
  36. end
  37. it "activate the already existing ticket 'type' field" do
  38. expect { process(process_payload) }.to change { ObjectManager::Attribute.get(object: 'Ticket', name: 'type').active }.from(false).to(true)
  39. end
  40. it "import the fixed option list for the ticket 'type' field" do
  41. process(process_payload)
  42. expect(ObjectManager::Attribute.get(object: 'Ticket', name: 'type').data_option[:options]).to include(imported_type_options)
  43. end
  44. end
  45. end
  46. end