models_spec.rb 758 B

123456789101112131415161718192021222324252627
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe Models do
  4. describe '.merge' do
  5. context 'when ExternalSync references are present' do
  6. shared_examples 'migrates entries' do |model|
  7. let(:factory_name) { model.downcase.to_sym }
  8. let(:source) { create(factory_name) }
  9. let(:target) { create(factory_name) }
  10. it 'sends ExternalSync.migrate' do
  11. allow(ExternalSync).to receive(:migrate)
  12. described_class.merge(model, source.id, target.id)
  13. expect(ExternalSync).to have_received(:migrate).with(model, source.id, target.id)
  14. end
  15. end
  16. it_behaves_like 'migrates entries', 'User'
  17. end
  18. end
  19. end