summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/migrations/migrate_build_stage_reference_spec.rb2
-rw-r--r--spec/migrations/migrate_pipeline_stages_spec.rb2
-rw-r--r--spec/spec_helper.rb6
-rw-r--r--spec/support/migrations_helpers.rb10
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 6a0e29f2edb..5cbb3dafcdf 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -94,10 +94,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