summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2017-09-02 20:56:53 -0700
committerStan Hu <stanhu@gmail.com>2017-09-02 20:56:53 -0700
commit0f8d7012138b9eec92ea0a42d63b10e363899aea (patch)
tree2cb00efccca5cfade5116c33550a00044c2bc1ca
parent2cec1c5484d4592f58c20362235d185c34ab6284 (diff)
downloadgitlab-ce-0f8d7012138b9eec92ea0a42d63b10e363899aea.tar.gz
Revert "Make it possible to provide schema version in tests"
This reverts commit 775cee737b585cc7fa943af21c1d09141952cbfe.
-rw-r--r--spec/lib/gitlab/background_migration/migrate_events_to_push_event_payloads_spec.rb21
-rw-r--r--spec/spec_helper.rb13
-rw-r--r--spec/support/migrations_helpers.rb15
3 files changed, 25 insertions, 24 deletions
diff --git a/spec/lib/gitlab/background_migration/migrate_events_to_push_event_payloads_spec.rb b/spec/lib/gitlab/background_migration/migrate_events_to_push_event_payloads_spec.rb
index 0d5fffa38ff..87f45619e7a 100644
--- a/spec/lib/gitlab/background_migration/migrate_events_to_push_event_payloads_spec.rb
+++ b/spec/lib/gitlab/background_migration/migrate_events_to_push_event_payloads_spec.rb
@@ -210,11 +210,7 @@ describe Gitlab::BackgroundMigration::MigrateEventsToPushEventPayloads::Event do
end
end
-##
-# The background migration relies on a temporary table, hence we're migrating
-# to a specific version of the database where said table is still present.
-#
-describe Gitlab::BackgroundMigration::MigrateEventsToPushEventPayloads, :migration, schema: 20170608152748 do
+describe Gitlab::BackgroundMigration::MigrateEventsToPushEventPayloads do
let(:migration) { described_class.new }
let(:project) { create(:project_empty_repo) }
let(:author) { create(:user) }
@@ -233,6 +229,21 @@ describe Gitlab::BackgroundMigration::MigrateEventsToPushEventPayloads, :migrati
)
end
+ # The background migration relies on a temporary table, hence we're migrating
+ # to a specific version of the database where said table is still present.
+ before :all do
+ ActiveRecord::Migration.verbose = false
+
+ ActiveRecord::Migrator
+ .migrate(ActiveRecord::Migrator.migrations_paths, 20170608152748)
+ end
+
+ after :all do
+ ActiveRecord::Migrator.migrate(ActiveRecord::Migrator.migrations_paths)
+
+ ActiveRecord::Migration.verbose = true
+ end
+
describe '#perform' do
it 'returns if data should not be migrated' do
allow(migration).to receive(:migrate?).and_return(false)
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 6f031860574..d35c82b293c 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -136,12 +136,17 @@ RSpec.configure do |config|
Sidekiq.redis(&:flushall)
end
- config.before(:context, :migration) do
- schema_migrate_down!
+ config.before(:example, :migration) do
+ ActiveRecord::Migrator
+ .migrate(migrations_paths, previous_migration.version)
+
+ reset_column_in_migration_models
end
- config.after(:context, :migration) do
- schema_migrate_up!
+ config.after(:example, :migration) do
+ ActiveRecord::Migrator.migrate(migrations_paths)
+
+ reset_column_in_migration_models
end
config.around(:each, :nested_groups) do |example|
diff --git a/spec/support/migrations_helpers.rb b/spec/support/migrations_helpers.rb
index dc64200a919..ef9d15016d1 100644
--- a/spec/support/migrations_helpers.rb
+++ b/spec/support/migrations_helpers.rb
@@ -33,21 +33,6 @@ 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