forum: delete posts when topic is deleted.
Fix it so that when a forum topic is deleted, all posts in the topic are deleted too. Also make it so that when a forum topic is undeleted, all posts in it are undeleted too. Before when a topic was deleted, only the topic itself was marked as deleted, not the posts inside the topic. This meant that when a spam topic was deleted, the OP wouldn't be marked as deleted, so any modreports against it wouldn't be marked as handled. Also change it so that it's not possible to undelete a post in a deleted topic, or to delete the OP of a topic without deleting the topic itself. Finally, add a fix script to delete all active posts in deleted topics, and to undelete all deleted OPs in active topics.
This commit is contained in:
@@ -306,11 +306,13 @@ class ForumTopicsControllerTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
end
|
||||
|
||||
should "destroy the topic and any associated posts" do
|
||||
should "mark the topic and all posts as deleted" do
|
||||
delete_auth forum_topic_path(@forum_topic), @mod
|
||||
assert_redirected_to(forum_topic_path(@forum_topic))
|
||||
@forum_topic.reload
|
||||
assert(@forum_topic.is_deleted?)
|
||||
|
||||
assert_redirected_to(@forum_topic)
|
||||
assert_equal(true, @forum_topic.reload.is_deleted?)
|
||||
assert_equal(true, @forum_topic.original_post.is_deleted?)
|
||||
assert_equal(true, @forum_topic.forum_posts.all?(&:is_deleted?))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -321,11 +323,13 @@ class ForumTopicsControllerTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
end
|
||||
|
||||
should "restore the topic" do
|
||||
should "mark the topic and all posts as undeleted" do
|
||||
post_auth undelete_forum_topic_path(@forum_topic), @mod
|
||||
assert_redirected_to(forum_topic_path(@forum_topic))
|
||||
@forum_topic.reload
|
||||
assert(!@forum_topic.is_deleted?)
|
||||
|
||||
assert_redirected_to(@forum_topic)
|
||||
assert_equal(false, @forum_topic.reload.is_deleted?)
|
||||
assert_equal(false, @forum_topic.original_post.is_deleted?)
|
||||
assert_equal(false, @forum_topic.forum_posts.all?(&:is_deleted?))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user