Commit 534524f2 authored by Alex Kalderimis's avatar Alex Kalderimis

Merge branch 'pl-db-schema-spec-fix' into 'master'

Check enums for _all_ defined models in development in specs

See merge request gitlab-org/gitlab!84448
parents 9f121326 c11aaba4
...@@ -180,21 +180,19 @@ RSpec.describe 'Database schema' do ...@@ -180,21 +180,19 @@ RSpec.describe 'Database schema' do
'PrometheusAlert' => %w[operator] 'PrometheusAlert' => %w[operator]
}.freeze }.freeze
context 'for enums' do context 'for enums', :eager_load do
ApplicationRecord.descendants.each do |model|
# skip model if it is an abstract class as it would not have an associated DB table # skip model if it is an abstract class as it would not have an associated DB table
next if model.abstract_class? let(:models) { ApplicationRecord.descendants.reject(&:abstract_class?) }
describe model do it 'uses smallint for enums in all models', :aggregate_failures do
let(:ignored_enums) { ignored_limit_enums(model.name) } models.each do |model|
let(:enums) { model.defined_enums.keys - ignored_enums } ignored_enums = ignored_limit_enums(model.name)
enums = model.defined_enums.keys - ignored_enums
it 'uses smallint for enums' do
expect(model).to use_smallint_for_enums(enums) expect(model).to use_smallint_for_enums(enums)
end end
end end
end end
end
# These pre-existing columns does not use a schema validation yet # These pre-existing columns does not use a schema validation yet
IGNORED_JSONB_COLUMNS = { IGNORED_JSONB_COLUMNS = {
......
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