Skip to content

Commit

Permalink
FIX: handle moving first post to a closed/archived topic
Browse files Browse the repository at this point in the history
  • Loading branch information
arpitjalan committed Jul 3, 2017
1 parent 72c92b0 commit 984778d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/models/post_mover.rb
Expand Up @@ -90,7 +90,8 @@ def create_first_post(post)
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)
Expand Down
13 changes: 13 additions & 0 deletions spec/models/post_mover_spec.rb
Expand Up @@ -391,6 +391,19 @@
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
Expand Down

0 comments on commit 984778d

Please sign in to comment.