freshdesk_spec.rb 2.1 KB

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