Commit c11aaba4 authored by Peter Leitzen's avatar Peter Leitzen Committed by Alex Kalderimis

Check enums for _all_ defined models in development

Previously, this spec only checked already loaded models (~192) and not
all available because we did not eager load the application.

Note that on CI (or with envvar `CI=1`) application is always loaded
eagerly.
parent 6cdba731
......@@ -180,18 +180,16 @@ RSpec.describe 'Database schema' do
'PrometheusAlert' => %w[operator]
}.freeze
context 'for enums' do
ApplicationRecord.descendants.each do |model|
# skip model if it is an abstract class as it would not have an associated DB table
next if model.abstract_class?
context 'for enums', :eager_load do
# skip model if it is an abstract class as it would not have an associated DB table
let(:models) { ApplicationRecord.descendants.reject(&:abstract_class?) }
describe model do
let(:ignored_enums) { ignored_limit_enums(model.name) }
let(:enums) { model.defined_enums.keys - ignored_enums }
it 'uses smallint for enums in all models', :aggregate_failures do
models.each do |model|
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)
end
expect(model).to use_smallint_for_enums(enums)
end
end
end
......
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