From d6b9a62e0a13497b8cc40eb1db56d1ec2b3760ea Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 19 Nov 2018 00:43:52 +0100 Subject: Extract counters from accounts table to account_stats table (#9295) --- spec/fabricators/account_stat_fabricator.rb | 6 ++++++ spec/models/account_spec.rb | 18 ------------------ spec/models/account_stat_spec.rb | 4 ++++ spec/models/notification_spec.rb | 2 +- spec/models/status_stat_spec.rb | 1 - 5 files changed, 11 insertions(+), 20 deletions(-) create mode 100644 spec/fabricators/account_stat_fabricator.rb create mode 100644 spec/models/account_stat_spec.rb (limited to 'spec') diff --git a/spec/fabricators/account_stat_fabricator.rb b/spec/fabricators/account_stat_fabricator.rb new file mode 100644 index 000000000..2b06b4790 --- /dev/null +++ b/spec/fabricators/account_stat_fabricator.rb @@ -0,0 +1,6 @@ +Fabricator(:account_stat) do + account nil + statuses_count "" + following_count "" + followers_count "" +end diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 60d13d32e..9133616a2 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -754,24 +754,6 @@ RSpec.describe Account, type: :model do expect(Account.suspended).to match_array([account_1]) end end - - describe 'without_followers' do - it 'returns a relation of accounts without followers' do - account_1 = Fabricate(:account) - account_2 = Fabricate(:account) - Fabricate(:follow, account: account_1, target_account: account_2) - expect(Account.without_followers).to match_array([account_1]) - end - end - - describe 'with_followers' do - it 'returns a relation of accounts with followers' do - account_1 = Fabricate(:account) - account_2 = Fabricate(:account) - Fabricate(:follow, account: account_1, target_account: account_2) - expect(Account.with_followers).to match_array([account_2]) - end - end end context 'when is local' do diff --git a/spec/models/account_stat_spec.rb b/spec/models/account_stat_spec.rb new file mode 100644 index 000000000..a94185109 --- /dev/null +++ b/spec/models/account_stat_spec.rb @@ -0,0 +1,4 @@ +require 'rails_helper' + +RSpec.describe AccountStat, type: :model do +end diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb index be5545646..403eb8c33 100644 --- a/spec/models/notification_spec.rb +++ b/spec/models/notification_spec.rb @@ -101,7 +101,7 @@ RSpec.describe Notification, type: :model do before do allow(accounts_with_ids).to receive(:[]).with(stale_account1.id).and_return(account1) allow(accounts_with_ids).to receive(:[]).with(stale_account2.id).and_return(account2) - allow(Account).to receive_message_chain(:where, :each_with_object).and_return(accounts_with_ids) + allow(Account).to receive_message_chain(:where, :includes, :each_with_object).and_return(accounts_with_ids) end let(:cached_items) do diff --git a/spec/models/status_stat_spec.rb b/spec/models/status_stat_spec.rb index 5e9351aff..af1a6f288 100644 --- a/spec/models/status_stat_spec.rb +++ b/spec/models/status_stat_spec.rb @@ -1,5 +1,4 @@ require 'rails_helper' RSpec.describe StatusStat, type: :model do - pending "add some examples to (or delete) #{__FILE__}" end -- cgit