From 9fb9ef418a58dbeeb568050a72e697f17c85afc3 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Thu, 18 Jan 2024 08:55:44 -0500 Subject: [PATCH] Fix `Rails/WhereExists` cop in User model (#28792) --- .rubocop_todo.yml | 1 - app/models/user.rb | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index eaa86ad15ad..87120daef2a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -85,7 +85,6 @@ Rails/WhereExists: - 'app/models/poll.rb' - 'app/models/session_activation.rb' - 'app/models/status.rb' - - 'app/models/user.rb' - 'app/policies/status_policy.rb' - 'app/serializers/rest/announcement_serializer.rb' - 'app/serializers/rest/tag_serializer.rb' diff --git a/app/models/user.rb b/app/models/user.rb index 5c90af56d28..70c24336f35 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -434,7 +434,7 @@ class User < ApplicationRecord end def sign_up_from_ip_requires_approval? - !sign_up_ip.nil? && IpBlock.where(severity: :sign_up_requires_approval).where('ip >>= ?', sign_up_ip.to_s).exists? + sign_up_ip.present? && IpBlock.sign_up_requires_approval.exists?(['ip >>= ?', sign_up_ip.to_s]) end def sign_up_email_requires_approval?