freshdesk_spec.rb 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. #
  4. # The purpose of this integration test is to verify that the API generally works.
  5. # Individual import steps are tested in spec/lib/sequencer.
  6. #
  7. RSpec.describe 'Freshdesk import', db_strategy: :reset, integration: true, required_envs: %w[IMPORT_FRESHDESK_ENDPOINT IMPORT_FRESHDESK_ENDPOINT_KEY IMPORT_FRESHDESK_ENDPOINT_SUBDOMAIN], use_vcr: true do # rubocop:disable RSpec/DescribeClass
  8. before do
  9. Setting.set('import_freshdesk_endpoint', ENV['IMPORT_FRESHDESK_ENDPOINT'])
  10. Setting.set('import_freshdesk_endpoint_key', ENV['IMPORT_FRESHDESK_ENDPOINT_KEY'])
  11. Setting.set('import_mode', true)
  12. Setting.set('system_init_done', false)
  13. VCR.use_cassette 'freshdesk_import' do
  14. ImportJob.create(name: 'Import::Freshdesk').start
  15. end
  16. end
  17. context 'when performing the full Freshdesk import' do
  18. let(:job) { ImportJob.last }
  19. let(:expected_stats) do
  20. {
  21. 'Groups' => {
  22. 'skipped' => 0,
  23. 'created' => 9,
  24. 'updated' => 0,
  25. 'unchanged' => 0,
  26. 'failed' => 0,
  27. 'deactivated' => 0,
  28. 'sum' => 9,
  29. 'total' => 9,
  30. },
  31. 'Users' => {
  32. 'skipped' => 0,
  33. 'created' => 18,
  34. 'updated' => 0,
  35. 'unchanged' => 0,
  36. 'failed' => 0,
  37. 'deactivated' => 0,
  38. 'sum' => 18,
  39. 'total' => 18,
  40. },
  41. 'Organizations' => {
  42. 'skipped' => 0,
  43. 'created' => 0,
  44. 'updated' => 1,
  45. 'unchanged' => 0,
  46. 'failed' => 0,
  47. 'deactivated' => 0,
  48. 'sum' => 1,
  49. 'total' => 1,
  50. },
  51. 'Tickets' => {
  52. 'skipped' => 0,
  53. 'created' => 13,
  54. 'updated' => 0,
  55. 'unchanged' => 0,
  56. 'failed' => 0,
  57. 'deactivated' => 0,
  58. 'sum' => 13,
  59. 'total' => 13,
  60. },
  61. }
  62. end
  63. it 'imports the correct number of expected objects' do
  64. expect(job.result).to eq expected_stats
  65. end
  66. end
  67. end