issue3123_external_sync_ticket_merge_spec.rb 1006 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe Issue3123ExternalSyncTicketMerge, type: :db_migration do
  4. let(:user) { create(:agent) }
  5. let(:source_ticket) { create(:ticket) }
  6. let(:target_ticket) { create(:ticket) }
  7. before do
  8. source_ticket.merge_to(
  9. ticket_id: target_ticket.id,
  10. user_id: user.id,
  11. )
  12. end
  13. context 'when no ExternalSync entries' do
  14. it "doesn't send ExternalSync.migrate" do
  15. allow(ExternalSync).to receive(:migrate)
  16. migrate
  17. expect(ExternalSync).not_to have_received(:migrate)
  18. end
  19. end
  20. context 'when ExternalSync entries present' do
  21. before do
  22. create(:external_sync, object: 'Ticket', o_id: source_ticket.id)
  23. end
  24. it 'sends ExternalSync.migrate' do
  25. allow(ExternalSync).to receive(:migrate)
  26. migrate
  27. expect(ExternalSync).to have_received(:migrate).with('Ticket', source_ticket.id, target_ticket.id)
  28. end
  29. end
  30. end