From c64444dea724646f489c86d013fd7ba2f4fd6c33 Mon Sep 17 00:00:00 2001 From: Christophe Bliard Date: Fri, 4 Mar 2022 17:01:32 +0100 Subject: [PATCH] Override type condition set by rails when scoping User some tests are order dependant and may fail without that when not all User descendants are loaded at the same time. It does not fail on CI because CI is eager loading all classes. For a failure, run: bundle exec rspec --order defined ./spec/models/queries/users/filters/name_filter_spec.rb:90 ./spec/models/queries/users/user_query_spec.rb:52 --- app/models/principals/scopes/user.rb | 2 +- spec/models/queries/users/user_query_spec.rb | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/app/models/principals/scopes/user.rb b/app/models/principals/scopes/user.rb index 0009e22dce..abf2ac99a9 100644 --- a/app/models/principals/scopes/user.rb +++ b/app/models/principals/scopes/user.rb @@ -37,7 +37,7 @@ module Principals::Scopes def user # Have to use the User model here so that the scopes defined on User # are also available after the scope is used. - where(type: [::User.name]) + rewhere(type: [::User.name]) end end end diff --git a/spec/models/queries/users/user_query_spec.rb b/spec/models/queries/users/user_query_spec.rb index 627f89d081..a5dfeab9c2 100644 --- a/spec/models/queries/users/user_query_spec.rb +++ b/spec/models/queries/users/user_query_spec.rb @@ -27,9 +27,6 @@ #++ require 'spec_helper' -# prevents test failures where the system user -# is mentioned in the User.user scope -require 'system_user' describe Queries::Users::UserQuery, type: :model do let(:instance) { described_class.new }