Draft: Add test for ActiveRecord callback changes
What does this MR do and why?
- Whenever an ActiveRecord model is changed, this spec will count the number of callbacks for all AR models. If the new count does not match the count in the fixture file, the spec will fail.
- If the person making the change decides to add the callback anyway, they can change the fixture file to make this spec pass.
- The idea here is not to disallow all changes to callback counts but to make developers more aware of this guideline and to consider whether a callback is really needed.
- Enforcement of style guideline !125836 (merged)
Co-authored-by: Peter Leitzen pleitzen@gitlab.com
Screenshots or screen recordings
This is what it looks like when it fails:
How to set up and validate locally
Add or remove a callback from any activerecord class, then run rspec spec/models/every_active_record_model_spec.rb
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.