Add common ThreadingHelper module for specs (#29116)

This commit is contained in:
Matt Jankowski 2024-02-07 09:53:29 -05:00 committed by GitHub
parent dbafec88e5
commit 95da28d201
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 40 additions and 57 deletions

View file

@ -1035,19 +1035,10 @@ RSpec.describe Account do
it 'increments the count in multi-threaded an environment when account_stat is not yet initialized' do
subject
increment_by = 15
wait_for_start = true
threads = Array.new(increment_by) do
Thread.new do
true while wait_for_start
described_class.find(subject.id).increment_count!(:followers_count)
end
multi_threaded_execution(15) do
described_class.find(subject.id).increment_count!(:followers_count)
end
wait_for_start = false
threads.each(&:join)
expect(subject.reload.followers_count).to eq 15
end
end