mirror of https://github.com/rails/rails
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
|
@ -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 New Issue