diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-06-05 13:16:26 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-06-05 13:16:26 +0200 |
commit | 3de144c09753b8ea04dbf19556611c4c690abfda (patch) | |
tree | 1f1cfb0e74a78228cd0e6dfb35e49f81fbe358e1 /spec | |
parent | 8808e7bcf518e16fa36762a9b01f6cf224233f06 (diff) | |
parent | 5b718d482584ad95caf25e0405a4eedb2bdc372e (diff) | |
download | gitlab-ce-3de144c09753b8ea04dbf19556611c4c690abfda.tar.gz |
Merge branch 'feature/gb/migrate-pipeline-stages' into feature/gb/persist-pipeline-stages
* feature/gb/migrate-pipeline-stages:
Calculate previous migration version in specs support
Conflicts:
spec/spec_helper.rb
Diffstat (limited to 'spec')
-rw-r--r-- | spec/migrations/migrate_build_stage_reference_spec.rb | 2 | ||||
-rw-r--r-- | spec/migrations/migrate_pipeline_stages_spec.rb | 2 | ||||
-rw-r--r-- | spec/spec_helper.rb | 6 | ||||
-rw-r--r-- | spec/support/migrations_helpers.rb | 10 |
4 files changed, 15 insertions, 5 deletions
diff --git a/spec/migrations/migrate_build_stage_reference_spec.rb b/spec/migrations/migrate_build_stage_reference_spec.rb index 979f13a1398..eaac8f95892 100644 --- a/spec/migrations/migrate_build_stage_reference_spec.rb +++ b/spec/migrations/migrate_build_stage_reference_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20170526185921_migrate_build_stage_reference.rb') -describe MigrateBuildStageReference, :migration, schema: 20170526185602 do +describe MigrateBuildStageReference, :migration do ## # Create test data - pipeline and CI/CD jobs. # diff --git a/spec/migrations/migrate_pipeline_stages_spec.rb b/spec/migrations/migrate_pipeline_stages_spec.rb index c9b38086deb..36d3bd13ac0 100644 --- a/spec/migrations/migrate_pipeline_stages_spec.rb +++ b/spec/migrations/migrate_pipeline_stages_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20170526185842_migrate_pipeline_stages.rb') -describe MigratePipelineStages, :migration, schema: 20170526185602 do +describe MigratePipelineStages, :migration do ## # Create test data - pipeline and CI/CD jobs. # diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a1e2791f496..d11e0cad066 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -97,10 +97,10 @@ RSpec.configure do |config| Sidekiq.redis(&:flushall) end - config.around(:example, migration: true) do |example| + config.around(:example, :migration) do |example| begin - schema_version = example.metadata.fetch(:schema) - ActiveRecord::Migrator.migrate(migrations_paths, schema_version) + ActiveRecord::Migrator + .migrate(migrations_paths, previous_migration.version) example.run ensure 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 |