diff --git a/app/models/post_mover.rb b/app/models/post_mover.rb index 1f26293b2c5..1d70519eaf6 100644 --- a/app/models/post_mover.rb +++ b/app/models/post_mover.rb @@ -90,7 +90,8 @@ class PostMover raw: post.raw, topic_id: destination_topic.id, acting_user: user, - skip_validations: true + skip_validations: true, + guardian: Guardian.new(user) ) PostAction.copy(post, new_post) diff --git a/spec/models/post_mover_spec.rb b/spec/models/post_mover_spec.rb index 24631d880c0..28abdc88763 100644 --- a/spec/models/post_mover_spec.rb +++ b/spec/models/post_mover_spec.rb @@ -391,6 +391,19 @@ describe PostMover do end end + context "to an existing closed topic" do + let!(:destination_topic) { Fabricate(:topic, closed: true) } + + it "works correctly for admin" do + admin = Fabricate(:admin) + moved_to = topic.move_posts(admin, [p1.id, p2.id], destination_topic_id: destination_topic.id) + expect(moved_to).to be_present + + moved_to.reload + expect(moved_to.posts_count).to eq(2) + expect(moved_to.highest_post_number).to eq(2) + end + end end end