active-hash / active_hash

A readonly ActiveRecord-esque base class that lets you use a hash, a Yaml file or a custom file as the datasource
MIT License
1.2k stars 179 forks source link

isolate tests with temporary classes #256

Closed machisuke closed 2 years ago

machisuke commented 2 years ago

background

ActiveRecord v5 and v6 uses ActiveSupport::Dependencies#constantize, ActiveSupport::Dependencies#saef_constantize which uses cached constantize results.

According to this, the above behavior is bug and fixed in ActiveRecord v7

changes

If the tests run with ActiveRecord v5 and v6, clear the cache in the before hook of all test cases to avoid ActiveRecord edge case bug.

note

Pulled out of https://github.com/active-hash/active_hash/pull/255

kbrock commented 2 years ago

@machisuke where are you seeing side effects of this bug? Are there particular tests that are having problems?