Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-08-17 12:59:00 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-08-17 12:59:00 +0300
commitd1cfa79dfc6c3bcec289d6951e08fd19ae155bdf (patch)
tree3ae9faf684a195000b1f91a92cf8f5994eb403b7 /spec/support
parent1066d8ba77ba242851c906aa523bd7548dad1d15 (diff)
parent56d24bcf80c7b6e93e298adb8214f4b2e97d094b (diff)
Merge branch 'backstage/gb/migrations-tests-schema-version' into backstage/gb/migrate-stages-statuses
* backstage/gb/migrations-tests-schema-version: Migrate down before each migration unit test Disable db_cleaner tables caching in migrations tests Extend migrations testing documentation Make it possible to provide schema version in tests Migrate db schema for context in :migration specs
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/db_cleaner.rb2
-rw-r--r--spec/support/migrations_helpers.rb15
2 files changed, 16 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..3e8c6b54c5a 100644
--- a/spec/support/migrations_helpers.rb
+++ b/spec/support/migrations_helpers.rb
@@ -31,6 +31,21 @@ module MigrationsHelpers
end
end
+ def migration_schema_version
+ self.class.metadata[:schema] || previous_migration.version
+ end
+
+ def schema_migrate_down!
+ ActiveRecord::Migrator
+ .migrate(migrations_paths, migration_schema_version)
+ reset_column_in_migration_models
+ end
+
+ def schema_migrate_up!
+ ActiveRecord::Migrator.migrate(migrations_paths)
+ reset_column_in_migration_models
+ end
+
def migrate!
ActiveRecord::Migrator.up(migrations_paths) do |migration|
migration.name == described_class.name