Loading
Add application-level presence validation for PushRule#project_id
What does this MR do and why?
Follow-up from !245553 (merged), which added a DB-level NOT NULL constraint (validate: false) on push_rules.project_id.
During review of !245553 (merged), @mkozono noted that our NOT NULL guidance recommends preventing new invalid records at the application level alongside the DB constraint, and suggested an explicit guard as a follow-up.
This MR adds that guard:
- Model (
ee/app/models/push_rule.rb): addpresence: trueforproject_idand dropallow_nilfrom the uniqueness validation. - Factory (
ee/spec/factories/push_rules.rb): remove the obsolete:push_rule_without_projectfactory — a projectless push rule is now an invalid record. - Spec (
ee/spec/models/push_rule_spec.rb): add presence coverage, update the uniqueness matcher, and replace the "allows nil project_id" test with one asserting nil is invalid. Remove the loose-foreign-key cleanup example for the legacy projectless org rule — org rules now live inorganization_push_rules, whose org-deletion cleanup is handled by a real DB foreign key (ON DELETE CASCADE).
Related
- Issue #606358 (closed)
Note
Some of the jobs in the NOT NULL MR failed because the test covers null records. We should merge this MR first and then we can merge it later.
Edited by Emma Park