zendesk_spec.rb 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'Zendesk import', db_strategy: :reset, integration: true, required_envs: %w[IMPORT_ZENDESK_ENDPOINT IMPORT_ZENDESK_ENDPOINT_KEY IMPORT_ZENDESK_ENDPOINT_USERNAME], use_vcr: true do # rubocop:disable RSpec/DescribeClass
  4. let(:job) { ImportJob.last }
  5. before do
  6. Setting.set('import_zendesk_endpoint', ENV['IMPORT_ZENDESK_ENDPOINT'])
  7. Setting.set('import_zendesk_endpoint_key', ENV['IMPORT_ZENDESK_ENDPOINT_KEY'])
  8. Setting.set('import_zendesk_endpoint_username', ENV['IMPORT_ZENDESK_ENDPOINT_USERNAME'])
  9. Setting.set('import_mode', true)
  10. Setting.set('system_init_done', false)
  11. VCR.use_cassette 'zendesk_import' do
  12. ImportJob.create(name: 'Import::Zendesk').start
  13. end
  14. end
  15. context 'when performing the full Zendesk import' do
  16. let(:job) { ImportJob.last }
  17. let(:expected_stats) do
  18. {
  19. 'Groups' => {
  20. 'skipped' => 0,
  21. 'created' => 2,
  22. 'updated' => 0,
  23. 'unchanged' => 0,
  24. 'failed' => 0,
  25. 'deactivated' => 0,
  26. 'sum' => 2,
  27. 'total' => 2,
  28. },
  29. 'Users' => {
  30. 'skipped' => 0,
  31. 'created' => 229,
  32. 'updated' => 1,
  33. 'unchanged' => 0,
  34. 'failed' => 0,
  35. 'deactivated' => 0,
  36. 'sum' => 230,
  37. 'total' => 230,
  38. },
  39. 'Organizations' => {
  40. 'skipped' => 0,
  41. 'created' => 1,
  42. 'updated' => 0,
  43. 'unchanged' => 1,
  44. 'failed' => 0,
  45. 'deactivated' => 0,
  46. 'sum' => 2,
  47. 'total' => 2,
  48. },
  49. 'Tickets' => {
  50. 'skipped' => 67,
  51. 'created' => 144,
  52. 'updated' => 1,
  53. 'unchanged' => 0,
  54. 'failed' => 0,
  55. 'deactivated' => 0,
  56. 'sum' => 212,
  57. 'total' => 212,
  58. },
  59. }
  60. end
  61. it 'imports the correct number of expected objects' do
  62. expect(job.result).to eq expected_stats
  63. end
  64. end
  65. end