mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix EagerLoadPolyAssocsTest setup (#38883)
* Fix EagerLoadPolyAssocsTest setup * EagerLoadPolyAssocsTest includes a Remembered module in multiple test ActiveRecord classes. The module is supposed to keep track of records created for each of the included classes individually, but it collects all records for every class. This happens because @@remembered is defined on the Remembered module and shared between the ActiveRecord classes. This only becomes an issue for databases (like CockroachDB) that use random primary keys instead of sequential ones by default. * To fix the bug, we can make the remembered collection name unique per ActiveRecord class. * Update EagerLoadPolyAssocsTest test setup * Instead of defining remembered as a class variable, we can define it as an instance variable that will be unique to every class that includes the Remembered module.
This commit is contained in:
parent
41139f6ba2
commit
834f5414c3
1 changed files with 2 additions and 2 deletions
|
@ -20,8 +20,8 @@ module Remembered
|
|||
end
|
||||
|
||||
module ClassMethods
|
||||
def remembered; @@remembered ||= []; end
|
||||
def sample; @@remembered.sample; end
|
||||
def remembered; @remembered ||= []; end
|
||||
def sample; remembered.sample; end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue