A platform for community discussion. Free, open, simple.
FIX: Do not move hidden post actions. (#7424)
Dan Ungureanua40dcbde9b8a
diff --git a/app/models/post_mover.rb b/app/models/post_mover.rbindex 2da1ca25258..c33449cc222 100644--- a/app/models/post_mover.rb+++ b/app/models/post_mover.rb@@ -224,6 +224,7 @@ class PostMover@posts ||= beginPost.where(topic: @original_topic, id: post_ids).where.not(post_type: Post.types[:small_action])+ .where.not(raw: '').order(:created_at).tap do |posts|raise Discourse::InvalidParameters.new(:post_ids) if posts.empty?diff --git a/spec/models/post_mover_spec.rb b/spec/models/post_mover_spec.rbindex c7eb777bd84..5d68a5db975 100644--- a/spec/models/post_mover_spec.rb+++ b/spec/models/post_mover_spec.rb@@ -258,10 +258,13 @@ describe PostMover doit "does not try to move small action posts" dosmall_action = Fabricate(:post, topic: topic, raw: "A small action", post_type: Post.types[:small_action])- new_topic = topic.move_posts(user, [p2.id, p4.id, small_action.id], title: "new testing topic name", category_id: category.id)+ hidden_small_action = Fabricate(:post, topic: topic, post_type: Post.types[:whisper])+ hidden_small_action.update_attribute(:raw, "")+ new_topic = topic.move_posts(user, [p2.id, p4.id, small_action.id, hidden_small_action.id], title: "new testing topic name", category_id: category.id)expect(new_topic.posts_count).to eq(2)expect(small_action.topic_id).to eq(topic.id)+ expect(hidden_small_action.topic_id).to eq(topic.id)moderator_post = topic.posts.lastexpect(moderator_post.raw).to include("2 posts were split")