Ensure project is persisted when generating new issue link
What does this MR do and why?
This ensures that a project actually exists before attempting to
generate the "Create issue" shortcut link for it. This fixes an issue
where, if you visited the "Create project" page as an admin with the new
nav enabled, the page would error-out. The reason seems to be that, on
that page, a Project
is instantiated, but not persisted, so the left
side of the condition passed, bringing us to the permission check. For
some reason, can?
returned true
, indicating that an admin is allowed
to create issues in a project that does not exist. This might be the
intended behavior though, and we should definitely check whether the
project is persisted first.
Screenshots or screen recordings
Before | After |
---|---|
How to set up and validate locally
- Sign-in as an admin.
- Enable the new nav:
- Navigate to the "New project" page at http://gdk.test:3000/projects/new.
- Before these changes, you should see an error 500. After the changes, the page should load normally.
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.