issue3123_external_sync_ticket_merge_spec.rb 920 B

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