activity_stream_spec.rb 855 B

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