Skip to content

AO3-7401 Show comments whose chapter no longer exists - #6122

Open
pmonfort wants to merge 2 commits into
otwcode:masterfrom
pmonfort:AO3-7401
Open

pmonfort wants to merge 2 commits into
otwcode:masterfrom
pmonfort:AO3-7401

Conversation

@pmonfort

Copy link
Copy Markdown
Contributor

Pull Request Checklist

Issue

https://otwarchive.atlassian.net/browse/AO3-7401

Purpose

Viewing a comment whose parent no longer exists gave a 500 error. For comments on works the parent is the chapter, not the parent comment, so this happens when the chapter is gone but the comment is still there. The "Reply" link is built from comment.parent.id, and add_comment_reply_link raised NoMethodError: undefined method 'id' for nil.

This PR:

  • Makes can_reply_to_comment? return false when the comment has no parent, so the "Reply" link isn't shown.
  • Shows the warning from the issue on the comment page, "This comment is part of a deleted thread. It will not be accessible in the overall comments section."
  • Adds controller specs for a reply whose chapter was deleted.

Testing Instructions

The steps in the issue delete the parent comment, which doesn't reproduce the error. These do, and need console access on test:

  1. Post a work, leave a comment on it and reply to that comment
  2. Click "Thread" on the reply and note the URL
  3. In a console, delete the chapter without callbacks with Comment.find(reply_id).parent.delete
  4. Reload the page from step 2

The comment should be shown with the warning above, and without a "Reply" link.

Credit

Pablo Monfort (he/him)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant