WIP: Refactor user namespace association
What does this MR do?
has_one :namespace association to be managed with
autosave instead of
It seems better to build/edit/validate namespace at the same time that the user is validated. If namespace validation fails,
user.valid? should return false, rather than raising an exception in
after_save and rolling back the transaction.
Are there points in the code the reviewer needs to double check?
Namespace both perform
dynamic_path validation. I've suppressed
dynamic_path validation on
Namespace if it is associated with a
User so it doesn't create duplicate looking errors.
But now I am a little worried that someone might later modify
Namespace directly instead of
User (this actually happened once recently), so I started adding custom
Namespace validation that checks that
name match the
kind == 'user'. The problem is a lot of existing code fundamentally assumes
Namespace can be used without
Group or a
User, so this validation causes a lot of non-trivial to fix errors. Should I forge ahead and require
Namespace to either be a
Group or have a
Why was this MR needed?
We were prevented from using a convenient
delegate :full_path, to: :namespace, allow_nil: true
because because we create the namespace
after_save, which makes namespace
full_pathnil) during validation on create, causing
DynamicPathValidatorto fail on user create.
Does this MR meet the acceptance criteria?
- Changelog entry added, if necessary
- Documentation created/updated
- API support added
- Added for this feature/bug
- All builds are passing
- Conform by the merge request performance guides
- Conform by the style guides
Branch has no merge conflicts with
master(if it does - rebase it please)
- Squashed related commits together
What are the relevant issue numbers?