Update parent link validate_max_children validation
What does this MR do and why?
Related to #451062 (closed)
When migrating epics to work items some parent epics could have more children than the limit set for parent links (100) but we need these links to remain valid after the backfilling. To achieve it, this MR modifies the validation validate_max_children
in WorkItems::ParentLink
model to be performed only when the parent changes so this will cover both create and update actions.
As these changes make the validation more lenient there is no risk involved for existing records.
Changelog: changed
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
How to set up and validate locally
- Enable feature flag
Feature.enable(:namespace_level_work_items)
- Visit any group work items URL and create a work item epic Parent Epic. E.g.
http://gdk.test:3000/groups/GROUP_PATH/-/work_items/new
- In the
child items
create and add 2 new child issues - Go to your IDE and open the file
app/models/work_items/parent_link.rb
to modify theMAX_CHILDREN
variable. Set a limit of 1. - Back in the browser try to add a new issue to Parent Epic, this should display an error because the limit has been reached
- Verify that the existing 2 children are valid by changing their position in the list (when invalid the update action for reordering would fail)
Edited by Eugenia Grieff