activity_stream_spec.rb 942 B

12345678910111213141516171819202122232425262728
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe Sessions::Backend::ActivityStream do
  4. context 'when async processes affect associated objects / DB records (#2066)' do
  5. subject(:activity_stream) { described_class.new(user, {}) }
  6. let(:user) { create(:agent, groups: [group]) }
  7. let(:group) { Group.find_by(name: 'Users') }
  8. let(:associated_tickets) { create_list(:ticket, ticket_count, group: group) }
  9. let(:ticket_count) { 20 }
  10. before do
  11. Setting.set('system_init_done', true)
  12. # these records must be created before the example begins
  13. # (same as `let!`, but harder to miss)
  14. associated_tickets
  15. end
  16. it 'manages race condition' do
  17. thread = Thread.new { associated_tickets.each(&:destroy) }
  18. expect { activity_stream.load }.not_to raise_error
  19. thread.join
  20. end
  21. end
  22. end