aboutsummaryrefslogtreecommitdiff
path: root/spec/models/account_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/account_spec.rb')
-rw-r--r--spec/models/account_spec.rb44
1 files changed, 23 insertions, 21 deletions
diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb
index 98d29e6f3..1d000ed4d 100644
--- a/spec/models/account_spec.rb
+++ b/spec/models/account_spec.rb
@@ -440,13 +440,6 @@ RSpec.describe Account, type: :model do
end
end
- describe '.domains' do
- it 'returns domains' do
- Fabricate(:account, domain: 'domain')
- expect(Account.remote.domains).to match_array(['domain'])
- end
- end
-
describe '#statuses_count' do
subject { Fabricate(:account) }
@@ -737,20 +730,6 @@ RSpec.describe Account, type: :model do
end
end
- describe 'by_domain_accounts' do
- it 'returns accounts grouped by domain sorted by accounts' do
- 2.times { Fabricate(:account, domain: 'example.com') }
- Fabricate(:account, domain: 'example2.com')
-
- results = Account.where('id > 0').by_domain_accounts
- expect(results.length).to eq 2
- expect(results.first.domain).to eq 'example.com'
- expect(results.first.accounts_count).to eq 2
- expect(results.last.domain).to eq 'example2.com'
- expect(results.last.accounts_count).to eq 1
- end
- end
-
describe 'local' do
it 'returns an array of accounts who do not have a domain' do
account_1 = Fabricate(:account, domain: nil)
@@ -817,4 +796,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