FIX: Do not move hidden post actions. (#7424)
Hidden (staff-only) post actions are whisper posts with no content, that are later transformed by the client into post actions (discourse-assign uses this).
This commit is contained in:
parent
d679c4e0eb
commit
a40dcbde9b
|
@ -224,6 +224,7 @@ class PostMover
|
|||
@posts ||= begin
|
||||
Post.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?
|
||||
|
|
|
@ -258,10 +258,13 @@ describe PostMover do
|
|||
|
||||
it "does not try to move small action posts" do
|
||||
small_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.last
|
||||
expect(moderator_post.raw).to include("2 posts were split")
|
||||
|
|
Loading…
Reference in New Issue