comments: allow votes to be soft deleted.
Make it so that when a user removes their own vote, the vote is soft deleted (the is_deleted flag is set) instead of hard deleted. Changes: * Add is_deleted flag to comment votes. * Relax uniqueness constraint so you can have multiple deleted votes on the same comment. You can still only have one active vote on the comment. * Add `soft_delete` method to Deletable concern.
This commit is contained in:
@@ -92,5 +92,16 @@ class CommentComponentTest < ViewComponent::TestCase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "for a comment with a deleted vote" do
|
||||
should "not treat the vote as active" do
|
||||
@user = create(:user)
|
||||
@vote = create(:comment_vote, user: @user, comment: @comment, is_deleted: true, score: 1)
|
||||
render_comment(@comment, current_user: @user)
|
||||
|
||||
assert_css("article.comment[data-is-upvoted=false]")
|
||||
assert_css("article.comment .comment-upvote-link.inactive-link")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user