Commit 56eaec7b authored by Rémy Coutable's avatar Rémy Coutable

Automatically add 'schema: :latest' to background migration specs

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 525e5135
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
# rubocop:disable RSpec/FactoriesInMigrationSpecs # rubocop:disable RSpec/FactoriesInMigrationSpecs
describe Gitlab::BackgroundMigration::BackfillVersionDataFromGitaly, schema: :latest do describe Gitlab::BackgroundMigration::BackfillVersionDataFromGitaly do
let(:issue) { create(:issue) } let(:issue) { create(:issue) }
def perform_worker def perform_worker
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration::MigrateApproverToApprovalRulesCheckProgress, schema: :latest do describe Gitlab::BackgroundMigration::MigrateApproverToApprovalRulesCheckProgress do
context 'when there is MigrateApproverToApprovalRulesInBatch jobs' do context 'when there is MigrateApproverToApprovalRulesInBatch jobs' do
it 'reschedules check' do it 'reschedules check' do
allow(Gitlab::BackgroundMigration).to receive(:exists?).with('MigrateApproverToApprovalRulesInBatch').and_return(true) allow(Gitlab::BackgroundMigration).to receive(:exists?).with('MigrateApproverToApprovalRulesInBatch').and_return(true)
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
# rubocop:disable RSpec/FactoriesInMigrationSpecs # rubocop:disable RSpec/FactoriesInMigrationSpecs
describe Gitlab::BackgroundMigration::MigrateApproverToApprovalRulesInBatch, schema: :latest do describe Gitlab::BackgroundMigration::MigrateApproverToApprovalRulesInBatch do
context 'when there is no more MigrateApproverToApprovalRules jobs' do context 'when there is no more MigrateApproverToApprovalRules jobs' do
let(:job) { double(:job) } let(:job) { double(:job) }
let(:project) { create(:project) } let(:project) { create(:project) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
# rubocop:disable RSpec/FactoriesInMigrationSpecs # rubocop:disable RSpec/FactoriesInMigrationSpecs
describe Gitlab::BackgroundMigration::MigrateApproverToApprovalRules, schema: :latest do describe Gitlab::BackgroundMigration::MigrateApproverToApprovalRules do
def create_skip_sync(*args) def create_skip_sync(*args)
build(*args) do |record| build(*args) do |record|
allow(record).to receive(:schedule_approval_migration) allow(record).to receive(:schedule_approval_migration)
......
...@@ -5,7 +5,7 @@ require './db/post_migrate/20191115115043_migrate_epic_mentions_to_db' ...@@ -5,7 +5,7 @@ require './db/post_migrate/20191115115043_migrate_epic_mentions_to_db'
require './db/post_migrate/20191115115522_migrate_epic_notes_mentions_to_db' require './db/post_migrate/20191115115522_migrate_epic_notes_mentions_to_db'
require './db/post_migrate/20200124110831_migrate_design_notes_mentions_to_db' require './db/post_migrate/20200124110831_migrate_design_notes_mentions_to_db'
describe Gitlab::BackgroundMigration::UserMentions::CreateResourceUserMention, schema: :latest do describe Gitlab::BackgroundMigration::UserMentions::CreateResourceUserMention do
include MigrationsHelpers include MigrationsHelpers
context 'when migrating data' do context 'when migrating data' do
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
# rubocop:disable RSpec/FactoriesInMigrationSpecs # rubocop:disable RSpec/FactoriesInMigrationSpecs
describe Gitlab::BackgroundMigration::BackfillProjectRepositories, schema: :latest do describe Gitlab::BackgroundMigration::BackfillProjectRepositories do
let(:group) { create(:group, name: 'foo', path: 'foo') } let(:group) { create(:group, name: 'foo', path: 'foo') }
describe described_class::ShardFinder do describe described_class::ShardFinder do
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
# rubocop: disable RSpec/FactoriesInMigrationSpecs # rubocop: disable RSpec/FactoriesInMigrationSpecs
describe Gitlab::BackgroundMigration::LegacyUploadMover, schema: :latest do describe Gitlab::BackgroundMigration::LegacyUploadMover do
let(:test_dir) { FileUploader.options['storage_path'] } let(:test_dir) { FileUploader.options['storage_path'] }
let(:filename) { 'image.png' } let(:filename) { 'image.png' }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
# rubocop: disable RSpec/FactoriesInMigrationSpecs # rubocop: disable RSpec/FactoriesInMigrationSpecs
describe Gitlab::BackgroundMigration::LegacyUploadsMigrator, schema: :latest do describe Gitlab::BackgroundMigration::LegacyUploadsMigrator do
let(:test_dir) { FileUploader.options['storage_path'] } let(:test_dir) { FileUploader.options['storage_path'] }
let!(:hashed_project) { create(:project) } let!(:hashed_project) { create(:project) }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration::MergeRequestAssigneesMigrationProgressCheck, schema: :latest do describe Gitlab::BackgroundMigration::MergeRequestAssigneesMigrationProgressCheck do
context 'rescheduling' do context 'rescheduling' do
context 'when there are ongoing and no dead jobs' do context 'when there are ongoing and no dead jobs' do
it 'reschedules check' do it 'reschedules check' do
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration, schema: :latest do describe Gitlab::BackgroundMigration do
describe '.queue' do describe '.queue' do
it 'returns background migration worker queue' do it 'returns background migration worker queue' do
expect(described_class.queue) expect(described_class.queue)
......
...@@ -81,6 +81,11 @@ RSpec.configure do |config| ...@@ -81,6 +81,11 @@ RSpec.configure do |config|
metadata[:migration] = true if metadata[:level] == :migration metadata[:migration] = true if metadata[:level] == :migration
end end
# Do not overwrite schema if it's already set
unless metadata.key?(:schema)
metadata[:schema] = :latest if quality_level.background_migration?(location)
end
# Do not overwrite type if it's already set # Do not overwrite type if it's already set
unless metadata.key?(:type) unless metadata.key?(:type)
match = location.match(%r{/spec/([^/]+)/}) match = location.match(%r{/spec/([^/]+)/})
......
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