Rework STI checks in model specs
What does this MR do and why?
This MR is a follow-up from !136649 (merged) and !138413 (merged) and improves how the use of STI in models is checked:
- It maps
spec/models/every_model_spec.rb
to every model change- This helps CI to fail fast
- It extracts STI check into a shared examples which is run in every model spec (via
type: :model
metadata)- This helps local feedback so the STI check is run whenever a model spec is run
- Remove
ApplicationRecord#new
patch fromDisablesSti
concern- This functionality is now covered by shared example
Using SKIP_STI_CHECK=1
to disable this check still works!
Refs #432960 (comment 1679921619).
How to set up and validate locally
bundle exec tff -f tests.yml app/models/project.rb
bundle exec tff -f tests.yml ee/app/models/weight_note.rb
bundle exec rspec spec/models/every_model_spec.rb
bundle exec rspec spec/models/project_spec.rb -e 'does not allow STI'
SKIP_STI_CHECK=1 bundle exec rspec spec/models/project_spec.rb -e 'does not allow STI'
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Peter Leitzen