Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stub the PG::Connection class instead of the migration class
Rails 7 changed the way migrations are run. The migration class constant is now removed and the file is reloaded between migrations. This means tests should not use expect/allow on migration stub classes as the constant stubbed is not the same constant the migration is run against. Additionally, comparisons of objects created before the migration with ones after will also not work. In that case, you can assert by id or other attributes instead of comparing objects. Rails also checks association classes are correct and will also not match expectations. For example, instead of using host to create or query the host association, use host_id instead. This also works with has_manys such as miq_product_feature_ids. See https://github.com/rails/rails/pull 42198
- Loading branch information