has_transaction_dispatcher_spec.rb 938 B

1234567891011121314151617181920212223242526
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe 'HasTransactionDispatcher', db_strategy: :reset, type: :model do
  4. let(:ticket) { create(:ticket) }
  5. let(:agent) { create(:agent, groups: [ticket.group]) }
  6. describe '#after_update' do
  7. context 'when ticket is updated without sending required values' do
  8. before do
  9. UserInfo.current_user_id = agent.id
  10. create(:object_manager_attribute_text, :required_screen)
  11. ObjectManager::Attribute.migration_execute
  12. end
  13. it 'does not call the TransactionDispatcher after_update hook', :aggregate_failures do
  14. allow(TransactionDispatcher).to receive(:after_update)
  15. expect { ticket.update(title: 'New title', screen: 'edit') }.to raise_error(Exceptions::ApplicationModel)
  16. expect(TransactionDispatcher).not_to have_received(:after_update)
  17. end
  18. end
  19. end
  20. end