FIX: handle moving first post to a closed/archived topic

This commit is contained in:
Arpit Jalan 2017-07-03 21:21:20 +05:30
parent 72c92b0f4e
commit 984778d3ac
2 changed files with 15 additions and 1 deletions

View File

@ -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)

View File

@ -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