]> source.dussan.org Git - redmine.git/commitdiff
Rails 6: Fix deprecation warning "Class level methods will no longer inherit scoping...
authorGo MAEDA <maeda@farend.jp>
Mon, 3 Feb 2020 15:12:21 +0000 (15:12 +0000)
committerGo MAEDA <maeda@farend.jp>
Mon, 3 Feb 2020 15:12:21 +0000 (15:12 +0000)
Patch by Pavel Rosický.

git-svn-id: http://svn.redmine.org/redmine/trunk@19490 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/user.rb
lib/redmine/acts/positioned.rb

index a837697a4504d742cb6e2aa6850a602a8103038d..76f479bcdb628e8ee96eec3e3b2b199e638a32d7 100644 (file)
@@ -634,7 +634,7 @@ class User < Principal
     Project.unscoped do
       return @project_ids_by_role if @project_ids_by_role
 
-      group_class = anonymous? ? GroupAnonymous : GroupNonMember
+      group_class = anonymous? ? GroupAnonymous.unscoped : GroupNonMember.unscoped
       group_id = group_class.pluck(:id).first
 
       members = Member.joins(:project, :member_roles).
@@ -970,7 +970,7 @@ class AnonymousUser < User
 
   def validate_anonymous_uniqueness
     # There should be only one AnonymousUser in the database
-    errors.add :base, 'An anonymous user already exists.' if AnonymousUser.exists?
+    errors.add :base, 'An anonymous user already exists.' if AnonymousUser.unscoped.exists?
   end
 
   def available_custom_fields
index bb7f80524e94e5ecbda1a81e187859dc52883861..f8134c6deb4c1727fc4a1c0800c5722b0aa6abd1 100644 (file)
@@ -66,7 +66,7 @@ module Redmine
             h[column] = yield(column)
             h
           end
-          self.class.where(condition_hash)
+          self.class.unscoped.where(condition_hash)
         end
 
         def set_default_position