Skip to content

Commit

Permalink
FIX: Do not move hidden post actions. (#7424)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
udan11 committed May 6, 2019
1 parent d679c4e commit a40dcbd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/models/post_mover.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ def posts
@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?
Expand Down
5 changes: 4 additions & 1 deletion spec/models/post_mover_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,13 @@

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")
Expand Down

0 comments on commit a40dcbd

Please sign in to comment.