Add test support code to migrate to a specific version
While we have spec support code for migrating to a specific version this depends on the test being a test for a database migration. Further, this code requires that described_class
returns the migration class. This means you can't re-use this code for background migrations that require a specific schema version, as is the case in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/12463/. For this particular MR I ended up doing the following:
before :all do
ActiveRecord::Migration.verbose = false
ActiveRecord::Migrator
.migrate(ActiveRecord::Migrator.migrations_paths, 20170608152748)
end
after :all do
ActiveRecord::Migrator.migrate(ActiveRecord::Migrator.migrations_paths)
ActiveRecord::Migration.verbose = true
end