From c753b1ad35ae84c21c0474bdb052833b2bd4463a Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Thu, 21 Dec 2023 04:18:38 -0500 Subject: [PATCH] Clean up of `RSpec/LetSetup` within `spec/models` (#28444) --- .rubocop_todo.yml | 3 --- spec/models/account_spec.rb | 1 + spec/models/canonical_email_block_spec.rb | 2 +- spec/models/user_spec.rb | 2 ++ 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 030f311101..bb2715f96e 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -63,11 +63,8 @@ RSpec/LetSetup: - 'spec/lib/activitypub/activity/delete_spec.rb' - 'spec/lib/vacuum/applications_vacuum_spec.rb' - 'spec/lib/vacuum/preview_cards_vacuum_spec.rb' - - 'spec/models/account_spec.rb' - 'spec/models/account_statuses_cleanup_policy_spec.rb' - - 'spec/models/canonical_email_block_spec.rb' - 'spec/models/status_spec.rb' - - 'spec/models/user_spec.rb' - 'spec/services/account_statuses_cleanup_service_spec.rb' - 'spec/services/activitypub/fetch_featured_collection_service_spec.rb' - 'spec/services/activitypub/fetch_remote_status_service_spec.rb' diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 522549125f..87aa8bc754 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -954,6 +954,7 @@ RSpec.describe Account do it 'returns every usable non-suspended account' do expect(described_class.searchable).to contain_exactly(silenced_local, silenced_remote, local_account, remote_account) + expect(described_class.searchable).to_not include(suspended_local, suspended_remote, unconfirmed, unapproved) end it 'does not mess with previously-applied scopes' do diff --git a/spec/models/canonical_email_block_spec.rb b/spec/models/canonical_email_block_spec.rb index 0acff82377..c63483f968 100644 --- a/spec/models/canonical_email_block_spec.rb +++ b/spec/models/canonical_email_block_spec.rb @@ -28,7 +28,7 @@ RSpec.describe CanonicalEmailBlock do end describe '.block?' do - let!(:canonical_email_block) { Fabricate(:canonical_email_block, email: 'foo@bar.com') } + before { Fabricate(:canonical_email_block, email: 'foo@bar.com') } it 'returns true for the same email' do expect(described_class.block?('foo@bar.com')).to be true diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 9111fd7c73..ab5bd39b7b 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -422,6 +422,7 @@ RSpec.describe User do it 'deactivates all sessions' do expect(user.session_activations.count).to eq 0 + expect { session_activation.reload }.to raise_error(ActiveRecord::RecordNotFound) end it 'revokes all access tokens' do @@ -430,6 +431,7 @@ RSpec.describe User do it 'removes push subscriptions' do expect(Web::PushSubscription.where(user: user).or(Web::PushSubscription.where(access_token: access_token)).count).to eq 0 + expect { web_push_subscription.reload }.to raise_error(ActiveRecord::RecordNotFound) end end