diff options
author | ThibG <thib@sitedethib.com> | 2020-11-12 22:57:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-12 22:57:57 +0100 |
commit | 3b6e27978d5d8851845c5c15bbe8162b998f59d3 (patch) | |
tree | a543d3e1de1f4f87607e7bd99630433dc0160e59 /spec | |
parent | 67125534bc0fd48a45d6cb17a5c78712d8e87150 (diff) | |
parent | 3f09d4ca034bc51b66b86bae7a10a41f02a4964f (diff) |
Merge pull request #1457 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/account_spec.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 98d29e6f3..75f628076 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -817,4 +817,27 @@ RSpec.describe Account, type: :model do include_examples 'AccountAvatar', :account include_examples 'AccountHeader', :account + + describe '#increment_count!' do + subject { Fabricate(:account) } + + 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 + Account.find(subject.id).increment_count!(:followers_count) + end + end + + wait_for_start = false + threads.each(&:join) + + expect(subject.reload.followers_count).to eq 15 + end + end end |