summaryrefslogtreecommitdiff
path: root/spec/support
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2017-08-18 23:26:19 -0700
committerStan Hu <stanhu@gmail.com>2017-08-18 23:26:19 -0700
commit841a5ef5be66a9a770cccf0d1520b501d0857155 (patch)
tree6a2fc1769d24deec5460b69f6e459527c64c19dd /spec/support
parent3e75b7fa81bfecbcbdbd68374049a161606d408b (diff)
parent84336b848caec71b9c2af2d826cf81e6a258f6e2 (diff)
downloadgitlab-ce-841a5ef5be66a9a770cccf0d1520b501d0857155.tar.gz
Merge branch 'master' into sh-headless-chrome-support
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/db_cleaner.rb2
-rw-r--r--spec/support/migrations_helpers.rb29
2 files changed, 30 insertions, 1 deletions
diff --git a/spec/support/db_cleaner.rb b/spec/support/db_cleaner.rb
index 7f5769209bb..b0f520d08e8 100644
--- a/spec/support/db_cleaner.rb
+++ b/spec/support/db_cleaner.rb
@@ -20,7 +20,7 @@ RSpec.configure do |config|
end
config.before(:each, :migration) do
- DatabaseCleaner.strategy = :truncation
+ DatabaseCleaner.strategy = :truncation, { cache_tables: false }
end
config.before(:each) do
diff --git a/spec/support/migrations_helpers.rb b/spec/support/migrations_helpers.rb
index aabdad13047..255b3d96a62 100644
--- a/spec/support/migrations_helpers.rb
+++ b/spec/support/migrations_helpers.rb
@@ -31,6 +31,35 @@ module MigrationsHelpers
end
end
+ def migration_schema_version
+ self.class.metadata[:schema] || previous_migration.version
+ end
+
+ def schema_migrate_down!
+ disable_migrations_output do
+ ActiveRecord::Migrator.migrate(migrations_paths,
+ migration_schema_version)
+ end
+
+ reset_column_in_migration_models
+ end
+
+ def schema_migrate_up!
+ disable_migrations_output do
+ ActiveRecord::Migrator.migrate(migrations_paths)
+ end
+
+ reset_column_in_migration_models
+ end
+
+ def disable_migrations_output
+ ActiveRecord::Migration.verbose = false
+
+ yield
+ ensure
+ ActiveRecord::Migration.verbose = true
+ end
+
def migrate!
ActiveRecord::Migrator.up(migrations_paths) do |migration|
migration.name == described_class.name