Update PreviewMarkdown to support references in personal snippets

What does this MR do and why?

Update PreviewMarkdown to support references in personal snippets.

The PreviewMarkdown concern wasn't passing :user in context for snippets; without a project, group or user, all reference parsing is skipped, so they simply didn't resolve in preview.

We pass user: current_user in the snippet preview context so fully-qualified cross-project references (e.g. group/project#nnn) resolve during live preview, same as when actually rendered on save.

Added an extra spec to assert CrossProjectReference's behaviour with only :user context.

References

Fixes Refactor preview markdown for PersonalSnippets (#232950).

Screenshots or screen recordings

Before After
image image

How to set up and validate locally

  1. Check out the branch locally.
  2. Ensure the personal_snippet_reference_filters FF is on for best results.
  3. Edit a personal snippet (start at http://gdk.test:3000/-/snippets), and type in a full reference to an issue/MR/work item.
  4. It should render correctly on save.
  5. Click edit again. In the rich-text editor, it should appear as a link. In the plain-text editor, "Preview" should also show it as a link correctly.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports

Loading