Merge remote-tracking branch 'parent/main' into upstream-20230209

This commit is contained in:
KMY 2024-02-09 12:53:59 +09:00
commit 05e52a09a8
188 changed files with 2810 additions and 1295 deletions

View file

@ -6,6 +6,8 @@ describe Account::Counters do
let!(:account) { Fabricate(:account) }
describe '#increment_count!' do
let(:increment_by) { 15 }
it 'increments the count' do
expect(account.followers_count).to eq 0
account.increment_count!(:followers_count)
@ -13,24 +15,17 @@ describe Account::Counters do
end
it 'increments the count in multi-threaded an environment' do
increment_by = 15
wait_for_start = true
threads = Array.new(increment_by) do
Thread.new do
true while wait_for_start
account.increment_count!(:statuses_count)
end
multi_threaded_execution(increment_by) do
account.increment_count!(:statuses_count)
end
wait_for_start = false
threads.each(&:join)
expect(account.statuses_count).to eq increment_by
end
end
describe '#decrement_count!' do
let(:decrement_by) { 10 }
it 'decrements the count' do
account.followers_count = 15
account.save!
@ -40,22 +35,13 @@ describe Account::Counters do
end
it 'decrements the count in multi-threaded an environment' do
decrement_by = 10
wait_for_start = true
account.statuses_count = 15
account.save!
threads = Array.new(decrement_by) do
Thread.new do
true while wait_for_start
account.decrement_count!(:statuses_count)
end
multi_threaded_execution(decrement_by) do
account.decrement_count!(:statuses_count)
end
wait_for_start = false
threads.each(&:join)
expect(account.statuses_count).to eq 5
end
end