A platform for community discussion. Free, open, simple.
FIX: Moderator actions and small actions shouldn't prevent fully merged topics from closing (#13200)
Andrei Prigorshnevb7b8f5e6f318
diff --git a/app/models/post_mover.rb b/app/models/post_mover.rbindex bedd483978b..8a7d351bfb2 100644--- a/app/models/post_mover.rb+++ b/app/models/post_mover.rb@@ -66,8 +66,6 @@ class PostMoverGuardian.new(user).ensure_can_see! topic@destination_topic = topic- moving_all_posts = (@original_topic.posts.pluck(:id).sort == @post_ids.sort)-create_temp_tabledelete_invalid_post_timingsmove_each_post@@ -78,7 +76,11 @@ class PostMoverupdate_upload_security_statusupdate_bookmarks- if moving_all_posts+ posts_left = @original_topic.posts+ .where("post_type = ? or (post_type = ? and action_code != 'split_topic')", Post.types[:regular], Post.types[:whisper])+ .count++ if posts_left == 1close_topic_and_schedule_deletionenddiff --git a/spec/models/post_mover_spec.rb b/spec/models/post_mover_spec.rbindex 05220dd93fa..11c3eef1361 100644--- a/spec/models/post_mover_spec.rb+++ b/spec/models/post_mover_spec.rb@@ -58,6 +58,14 @@ describe PostMover do@like = PostActionCreator.like(another_user, p4)end+ def add_moderator_post_to(topic, post_type)+ topic.add_moderator_post(+ user,+ "message",+ post_type: post_type,+ action_code: "split_topic")+ end+context 'success' doit "correctly handles notifications and bread crumbs" do@@ -664,6 +672,17 @@ describe PostMover doexpect(timer).to be_nilend+ it "ignores moderator posts and closes the topic if all regular posts were moved" do+ add_moderator_post_to topic, Post.types[:moderator_action]+ add_moderator_post_to topic, Post.types[:small_action]++ posts_to_move = [p1.id, p2.id, p3.id, p4.id]+ topic.move_posts(user, posts_to_move, destination_topic_id: destination_topic.id)++ topic.reload+ expect(topic).to be_closed+ end+it "does not try to move small action posts" dosmall_action = Fabricate(:post, topic: topic, raw: "A small action", post_type: Post.types[:small_action])moved_to = topic.move_posts(user, [p1.id, p2.id, p3.id, p4.id, small_action.id], destination_topic_id: destination_topic.id)