From ae45c9ccd41a28cff5e9b6cbacaf99f36cf57048 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Wed, 8 Feb 2023 04:39:57 -0500 Subject: [PATCH] Apply Rubocop Rails/WhereNot (#23448) * Apply Rubocop Rails/WhereNot * Update spec for where.not --- app/lib/vacuum/access_tokens_vacuum.rb | 4 ++-- app/models/session_activation.rb | 2 +- spec/models/session_activation_spec.rb | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/lib/vacuum/access_tokens_vacuum.rb b/app/lib/vacuum/access_tokens_vacuum.rb index 4f3878027a..7b91f74a51 100644 --- a/app/lib/vacuum/access_tokens_vacuum.rb +++ b/app/lib/vacuum/access_tokens_vacuum.rb @@ -9,10 +9,10 @@ class Vacuum::AccessTokensVacuum private def vacuum_revoked_access_tokens! - Doorkeeper::AccessToken.where('revoked_at IS NOT NULL').where('revoked_at < NOW()').delete_all + Doorkeeper::AccessToken.where.not(revoked_at: nil).where('revoked_at < NOW()').delete_all end def vacuum_revoked_access_grants! - Doorkeeper::AccessGrant.where('revoked_at IS NOT NULL').where('revoked_at < NOW()').delete_all + Doorkeeper::AccessGrant.where.not(revoked_at: nil).where('revoked_at < NOW()').delete_all end end diff --git a/app/models/session_activation.rb b/app/models/session_activation.rb index 3a59bad939..0b7fa6fe49 100644 --- a/app/models/session_activation.rb +++ b/app/models/session_activation.rb @@ -59,7 +59,7 @@ class SessionActivation < ApplicationRecord end def exclusive(id) - where('session_id != ?', id).destroy_all + where.not(session_id: id).destroy_all end end diff --git a/spec/models/session_activation_spec.rb b/spec/models/session_activation_spec.rb index 450dc1399f..8db06c6227 100644 --- a/spec/models/session_activation_spec.rb +++ b/spec/models/session_activation_spec.rb @@ -118,8 +118,8 @@ RSpec.describe SessionActivation, type: :model do let(:id) { '1' } it 'calls where.destroy_all' do - expect(described_class).to receive_message_chain(:where, :destroy_all) - .with('session_id != ?', id).with(no_args) + expect(described_class).to receive_message_chain(:where, :not, :destroy_all) + .with(session_id: id).with(no_args) described_class.exclusive(id) end