diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
commit | 3cccd102ba543e02725d247893729e5c73b38295 (patch) | |
tree | f36a04ec38517f5deaaacb5acc7d949688d1e187 /spec/db/migration_spec.rb | |
parent | 205943281328046ef7b4528031b90fbda70c75ac (diff) |
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'spec/db/migration_spec.rb')
-rw-r--r-- | spec/db/migration_spec.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/db/migration_spec.rb b/spec/db/migration_spec.rb new file mode 100644 index 00000000000..ac649925751 --- /dev/null +++ b/spec/db/migration_spec.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Migrations Validation' do + using RSpec::Parameterized::TableSyntax + + # The range describes the timestamps that given migration helper can be used + let(:all_migration_classes) do + { + 2022_01_26_21_06_58.. => Gitlab::Database::Migration[2.0], + 2021_09_01_15_33_24.. => Gitlab::Database::Migration[1.0], + 2021_05_31_05_39_16..2021_09_01_15_33_24 => ActiveRecord::Migration[6.1], + ..2021_05_31_05_39_16 => ActiveRecord::Migration[6.0] + } + end + + where(:migration) do + Gitlab::Database.database_base_models.flat_map do |_, model| + model.connection.migration_context.migrations + end.uniq + end + + with_them do + let(:migration_instance) { migration.send(:migration) } + let(:allowed_migration_classes) { all_migration_classes.select { |r, _| r.include?(migration.version) }.values } + + it 'uses one of the allowed migration classes' do + expect(allowed_migration_classes).to include(be > migration_instance.class) + end + end +end |