DEV: Don't polute all ActiveRecord classes (#15103)

`pending`, `approved`, `rejected`, `ignored`, and `deleted` scope method were accessible on all model classes… 😂

Fixes `Creating scope :pending. Overwriting existing method DiscoursePostEvent::EventDate.pending.` warnings.
This commit is contained in:
Jarek Radosz 2021-11-26 03:17:10 +01:00 committed by GitHub
parent 73db60ad2a
commit 1441226b1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -80,7 +80,7 @@ class Reviewable < ActiveRecord::Base
# Generate `pending?`, `rejected?`, etc helper methods
statuses.each do |name, id|
define_method("#{name}?") { status == id }
self.class.define_method(name) { where(status: id) }
singleton_class.define_method(name) { where(status: id) }
end
def self.default_visible