Sync project namespace on before_save when validation skipped

What does this MR do and why

In app/models/project.rb, the ensure_project_namespace_in_sync callback was registered only as before_validation. This callback syncs a project's namespace_id to the project namespace's parent_id (part of SYNCED_ATTRIBUTES), which triggers traversal callbacks that recompute traversal_ids.

Any write that changes namespace_id and saves with validate: false silently skipped this sync, leaving the project namespace's parent_id / traversal_ids drifted — even though the route and projects.namespace_id were updated correctly, since route callbacks fire on before_save.

This MR also registers ensure_project_namespace_in_sync as a before_save callback (in case validation is skipped), mirroring the existing pattern for Routable#prepare_route, which registers prepare_route on both before_validation and before_save for the same reason.

How to test

Run the new regression spec in spec/models/project_spec.rb, which assigns changed attributes and calls save!(validate: false), then asserts the project namespace is in sync with the project.

Closes #616993 (closed)

Merge request reports

Loading
Loading