summaryrefslogtreecommitdiff
path: root/spec/support
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-06-05 11:07:10 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-06-05 11:07:10 +0200
commit028423c2f51ff738d151df32254913664ac8e898 (patch)
treedf1a1e0b801d201e7ebfe64186663c7a591eb897 /spec/support
parent1a438e9f710edfa50408d93a363a240bdcd532c1 (diff)
downloadgitlab-ce-028423c2f51ff738d151df32254913664ac8e898.tar.gz
Calculate previous migration version in specs support
This makes it possible to test migration on the schema this migration was written for, without a need to specify a previous schema version manually.
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/migrations_helpers.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/spec/support/migrations_helpers.rb b/spec/support/migrations_helpers.rb
index ee17d1a40b7..91fbb4eaf48 100644
--- a/spec/support/migrations_helpers.rb
+++ b/spec/support/migrations_helpers.rb
@@ -11,6 +11,16 @@ module MigrationsHelpers
ActiveRecord::Base.connection.table_exists?(name)
end
+ def migrations
+ ActiveRecord::Migrator.migrations(migrations_paths)
+ end
+
+ def previous_migration
+ migrations.each_cons(2) do |previous, migration|
+ break previous if migration.name == described_class.name
+ end
+ end
+
def migrate!
ActiveRecord::Migrator.up(migrations_paths) do |migration|
migration.name == described_class.name