comments: rework deleted comments.
Let users see when a post has deleted comments. Show normal users a '[deleted]' placeholder when a comment is deleted. Show the full comment to moderators. Also fix it so that the comment creator can't edit or undelete deleted comments, and users can't vote on or report deleted comments. Finally, hide the creator_id, updater_id, and body of deleted comments in the API.
This commit is contained in:
@@ -26,6 +26,29 @@ class CommentComponentTest < ViewComponent::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
context "for a deleted comment" do
|
||||
setup do
|
||||
@deleted_comment = as(create(:user)) { create(:comment, is_deleted: true) }
|
||||
end
|
||||
|
||||
should "have the creator and body hidden for a Member" do
|
||||
render_comment(@deleted_comment, current_user: @deleted_comment.creator)
|
||||
|
||||
assert_css("article[data-is-dimmed=true]")
|
||||
assert_css("article .author-name", text: "[deleted]")
|
||||
assert_css("article .body p", text: "[deleted]")
|
||||
end
|
||||
|
||||
should "be visible for a Moderator" do
|
||||
render_comment(@deleted_comment, current_user: create(:moderator_user))
|
||||
|
||||
assert_css("article[data-is-dimmed=true]")
|
||||
assert_no_css("article .unhide-comment-link")
|
||||
assert_css("article .author-name", text: @deleted_comment.creator.pretty_name)
|
||||
assert_css("article .body p", text: @deleted_comment.body)
|
||||
end
|
||||
end
|
||||
|
||||
context "for a comment with moderation reports" do
|
||||
should "show the report notice to moderators" do
|
||||
create(:moderation_report, model: @comment)
|
||||
|
||||
Reference in New Issue
Block a user