mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FIX: Couldn't move posts with deleted replies
This commit is contained in:
parent
f10c4682cd
commit
e5b529f8e1
2 changed files with 15 additions and 4 deletions
|
@ -78,7 +78,7 @@ class PostMover
|
||||||
end
|
end
|
||||||
|
|
||||||
PostReply.where("reply_id in (:post_ids) OR post_id in (:post_ids)", post_ids: post_ids).each do |post_reply|
|
PostReply.where("reply_id in (:post_ids) OR post_id in (:post_ids)", post_ids: post_ids).each do |post_reply|
|
||||||
if post_reply.reply.topic_id != post_reply.post.topic_id
|
if post_reply.post && post_reply.reply && post_reply.reply.topic_id != post_reply.post.topic_id
|
||||||
PostReply.delete_all(reply_id: post_reply.reply.id, post_id: post_reply.post.id)
|
PostReply.delete_all(reply_id: post_reply.reply.id, post_id: post_reply.post.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -80,7 +80,18 @@ describe PostMover do
|
||||||
topic.move_posts(
|
topic.move_posts(
|
||||||
user,
|
user,
|
||||||
[p2.id],
|
[p2.id],
|
||||||
title: 'GOT is a very addictive showw', category_id: category.id
|
title: 'GOT is a very addictive show', category_id: category.id
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(p2.reload.replies).to eq([])
|
||||||
|
end
|
||||||
|
|
||||||
|
it "doesn't raise errors with deleted replies" do
|
||||||
|
p4.trash!
|
||||||
|
topic.move_posts(
|
||||||
|
user,
|
||||||
|
[p2.id],
|
||||||
|
title: 'GOT is a very addictive show', category_id: category.id
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(p2.reload.replies).to eq([])
|
expect(p2.reload.replies).to eq([])
|
||||||
|
@ -101,7 +112,7 @@ describe PostMover do
|
||||||
topic.move_posts(
|
topic.move_posts(
|
||||||
user,
|
user,
|
||||||
[p4.id],
|
[p4.id],
|
||||||
title: 'GOT is a very addictive showw', category_id: category.id
|
title: 'GOT is a very addictive show', category_id: category.id
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(p2.reload.replies).to eq([p5])
|
expect(p2.reload.replies).to eq([p5])
|
||||||
|
@ -122,7 +133,7 @@ describe PostMover do
|
||||||
topic.move_posts(
|
topic.move_posts(
|
||||||
user,
|
user,
|
||||||
[p2.id, p4.id],
|
[p2.id, p4.id],
|
||||||
title: 'GOT is a very addictive showw', category_id: category.id
|
title: 'GOT is a very addictive show', category_id: category.id
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(p2.reload.replies).to eq([p4])
|
expect(p2.reload.replies).to eq([p4])
|
||||||
|
|
Loading…
Reference in a new issue