2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2018-07-20 05:08:26 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe Sessions::Backend::ActivityStream do
|
|
|
|
context 'when async processes affect associated objects / DB records (#2066)' do
|
2021-09-22 06:53:16 +00:00
|
|
|
subject(:activity_stream) { described_class.new(user, {}) }
|
|
|
|
|
2020-06-19 09:17:18 +00:00
|
|
|
let(:user) { create(:agent, groups: [group]) }
|
2018-07-20 05:08:26 +00:00
|
|
|
let(:group) { Group.find_by(name: 'Users') }
|
|
|
|
let(:associated_tickets) { create_list(:ticket, ticket_count, group: group) }
|
|
|
|
let(:ticket_count) { 20 }
|
|
|
|
|
|
|
|
before do
|
|
|
|
Setting.set('system_init_done', true)
|
|
|
|
|
|
|
|
# these records must be created before the example begins
|
|
|
|
# (same as `let!`, but harder to miss)
|
|
|
|
associated_tickets
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'manages race condition' do
|
2018-07-24 19:55:02 +00:00
|
|
|
thread = Thread.new { associated_tickets.each(&:destroy) }
|
2021-09-22 06:53:16 +00:00
|
|
|
expect { activity_stream.load }.not_to raise_error
|
2018-07-24 19:55:02 +00:00
|
|
|
thread.join
|
2018-07-20 05:08:26 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|