Commit 3de144c0 authored by Grzegorz Bizon's avatar Grzegorz Bizon

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
parents 8808e7bc 5b718d48
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.
#
......
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.
#
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment