group_spec.rb 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. require 'zendesk_api'
  4. RSpec.describe Sequencer::Sequence::Import::Zendesk::Group, sequencer: :sequence do
  5. context 'when importing groups from Zendesk' do
  6. let(:base_resource) do
  7. ZendeskAPI::Group.new(
  8. nil,
  9. {
  10. 'id' => 24_165_105,
  11. 'name' => 'Additional Group',
  12. 'description' => '',
  13. 'default' => false,
  14. 'created_at' => '2015-12-04 13:11:59 UTC',
  15. 'updated_at' => '2015-12-04 13:11:59 UTC'
  16. }
  17. )
  18. end
  19. let(:process_payload) do
  20. {
  21. import_job: build_stubbed(:import_job, name: 'Import::Zendesk', payload: {}),
  22. dry_run: false,
  23. resource: resource,
  24. field_map: {},
  25. }
  26. end
  27. context 'with active group' do
  28. let(:resource) do
  29. base_resource.merge('deleted' => false)
  30. end
  31. it 'adds groups', :aggregate_failures do
  32. expect { process(process_payload) }.to change(Group, :count).by(1)
  33. expect(Group.last).to have_attributes(
  34. name: 'Additional Group',
  35. active: true,
  36. )
  37. end
  38. end
  39. context 'with inactive group' do
  40. let(:resource) do
  41. base_resource.merge('deleted' => true)
  42. end
  43. it 'adds groups', :aggregate_failures do
  44. expect { process(process_payload) }.to change(Group, :count).by(1)
  45. expect(Group.last).to have_attributes(
  46. name: 'Additional Group',
  47. active: false,
  48. )
  49. end
  50. end
  51. end
  52. end