0
0
Fork 0

Update rubocop-rspec to version 2.22.0, fix RSpec/IndexedLet cop (#24698)

This commit is contained in:
Matt Jankowski 2023-06-14 10:44:37 -04:00 committed by GitHub
parent 24015ef0cc
commit 4c5aa0e470
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 334 additions and 322 deletions

View file

@ -5,12 +5,12 @@ require 'rails_helper'
describe Scheduler::AccountsStatusesCleanupScheduler do
subject { described_class.new }
let!(:account1) { Fabricate(:account, domain: nil) }
let!(:account2) { Fabricate(:account, domain: nil) }
let!(:account3) { Fabricate(:account, domain: nil) }
let!(:account4) { Fabricate(:account, domain: nil) }
let!(:account5) { Fabricate(:account, domain: nil) }
let!(:remote) { Fabricate(:account) }
let!(:account_alice) { Fabricate(:account, domain: nil, username: 'alice') }
let!(:account_bob) { Fabricate(:account, domain: nil, username: 'bob') }
let!(:account_chris) { Fabricate(:account, domain: nil, username: 'chris') }
let!(:account_dave) { Fabricate(:account, domain: nil, username: 'dave') }
let!(:account_erin) { Fabricate(:account, domain: nil, username: 'erin') }
let!(:remote) { Fabricate(:account) }
let(:queue_size) { 0 }
let(:queue_latency) { 0 }
@ -77,26 +77,26 @@ describe Scheduler::AccountsStatusesCleanupScheduler do
describe '#perform' do
before do
# Policies for the accounts
Fabricate(:account_statuses_cleanup_policy, account: account1)
Fabricate(:account_statuses_cleanup_policy, account: account3)
Fabricate(:account_statuses_cleanup_policy, account: account4, enabled: false)
Fabricate(:account_statuses_cleanup_policy, account: account5)
Fabricate(:account_statuses_cleanup_policy, account: account_alice)
Fabricate(:account_statuses_cleanup_policy, account: account_chris)
Fabricate(:account_statuses_cleanup_policy, account: account_dave, enabled: false)
Fabricate(:account_statuses_cleanup_policy, account: account_erin)
# Create a bunch of old statuses
4.times do
Fabricate(:status, account: account1, created_at: 3.years.ago)
Fabricate(:status, account: account2, created_at: 3.years.ago)
Fabricate(:status, account: account3, created_at: 3.years.ago)
Fabricate(:status, account: account4, created_at: 3.years.ago)
Fabricate(:status, account: account5, created_at: 3.years.ago)
Fabricate(:status, account: account_alice, created_at: 3.years.ago)
Fabricate(:status, account: account_bob, created_at: 3.years.ago)
Fabricate(:status, account: account_chris, created_at: 3.years.ago)
Fabricate(:status, account: account_dave, created_at: 3.years.ago)
Fabricate(:status, account: account_erin, created_at: 3.years.ago)
Fabricate(:status, account: remote, created_at: 3.years.ago)
end
# Create a bunch of newer statuses
Fabricate(:status, account: account1, created_at: 3.minutes.ago)
Fabricate(:status, account: account2, created_at: 3.minutes.ago)
Fabricate(:status, account: account3, created_at: 3.minutes.ago)
Fabricate(:status, account: account4, created_at: 3.minutes.ago)
Fabricate(:status, account: account_alice, created_at: 3.minutes.ago)
Fabricate(:status, account: account_bob, created_at: 3.minutes.ago)
Fabricate(:status, account: account_chris, created_at: 3.minutes.ago)
Fabricate(:status, account: account_dave, created_at: 3.minutes.ago)
Fabricate(:status, account: remote, created_at: 3.minutes.ago)
end
@ -106,8 +106,8 @@ describe Scheduler::AccountsStatusesCleanupScheduler do
expect { subject.perform }
.to change(Status, :count).by(-subject.compute_budget) # Cleanable statuses
.and (not_change { account2.statuses.count }) # No cleanup policy for account
.and(not_change { account4.statuses.count }) # Disabled cleanup policy
.and (not_change { account_bob.statuses.count }) # No cleanup policy for account
.and(not_change { account_dave.statuses.count }) # Disabled cleanup policy
end
it 'eventually deletes every deletable toot given enough runs' do
@ -122,9 +122,9 @@ describe Scheduler::AccountsStatusesCleanupScheduler do
expect { 3.times { subject.perform } }
.to change(Status, :count).by(-3 * 3)
.and change { account1.statuses.count }
.and change { account3.statuses.count }
.and(change { account5.statuses.count })
.and change { account_alice.statuses.count }
.and change { account_chris.statuses.count }
.and(change { account_erin.statuses.count })
end
context 'when given a big budget' do
@ -156,7 +156,7 @@ describe Scheduler::AccountsStatusesCleanupScheduler do
def cleanable_statuses_count
Status
.where(account_id: [account1, account3, account5]) # Accounts with enabled policies
.where(account_id: [account_alice, account_chris, account_erin]) # Accounts with enabled policies
.where('created_at < ?', 2.weeks.ago) # Policy defaults is 2.weeks
.count
end