Rendering (closed) does not work correctly for newly closed issues

Summary

When an issue is closed it should be rendered with "(closed)" appendix. That however does not work properly for issues closed after the link is inserted.

This behavior happens for both description and comments.

Steps to reproduce

  1. create a project
  2. create issue A in that project (#1)
  3. create issue B in that project (#2), mention issue A in the description
  4. close issue A
  5. reload the page

What is the current bug behavior?

First the text is rendered correctly (#1 (closed) is rendered) but then the text changes to #1 and closed is removed

What is the expected correct behavior?

The text is rendered correctly (#1 (closed))

Relevant logs and/or screenshots

issue_close

Output of checks

This bug happens on GitLab.com

Possible fixes

The IssuableStateFilter works correctly, correct text is still in https://gitlab.com/gitlab-org/gitlab-ce/blob/master/app/views/projects/issues/show.html.haml#L64 . I suppose something happens afterwards.

Also probably after the html field on the issue (description_html) is updated it works correctly.