ActiveRecord Migrator improvements in test env do not work correctly
Summary
https://gitlab.com/gitlab-org/gitlab-ce/blob/master/config/initializers/ar_speed_up_migration_checking.rb makes ActiveRecord::Migrator
to be not idempotent any more.
Calling ActiveRecord::Migrator.migrate
multiple times fails. Somehow @migrations class-level instance variable is altered.
Why it is a problem?
Following around
hook in RSpec doesn't work as intended.
config.around(:each, :migration) do |example|
begin
schema_version = example.metadata.fetch(:schema)
ActiveRecord::Migrator.migrate(migrations_paths, schema_version)
example.run
ensure
ActiveRecord::Migrator.migrate(migrations_paths)
end
end
ActiveRecord::Migrator.migrations(migrations_paths)
returns different data when testing multiple examples at once (should be idempotent).
/cc @nick.thomas
Edited by Grzegorz Bizon