mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-01 13:20:41 +01:00
fix: #8317
This commit is contained in:
@@ -52,6 +52,14 @@ module.exports = function (Topics) {
|
||||
|
||||
await Topics.updateLastPostTime(tid, Date.now());
|
||||
|
||||
await Promise.all([
|
||||
Topics.setTopicFields(tid, {
|
||||
upvotes: postData.upvotes,
|
||||
downvotes: postData.downvotes,
|
||||
}),
|
||||
db.sortedSetsAdd(['topics:votes', 'cid:' + cid + ':tids:votes'], postData.votes, tid),
|
||||
]);
|
||||
|
||||
plugins.fireHook('action:topic.fork', { tid: tid, fromTid: fromTid, uid: uid });
|
||||
|
||||
return await Topics.getTopicData(tid);
|
||||
|
||||
@@ -906,6 +906,22 @@ describe('Topic\'s', function () {
|
||||
},
|
||||
], done);
|
||||
});
|
||||
|
||||
it('should properly update topic vote count after forking', async () => {
|
||||
const result = await topics.post({ uid: fooUid, cid: categoryObj.cid, title: 'fork vote test', content: 'main post' });
|
||||
const reply1 = await topics.reply({ tid: result.topicData.tid, uid: fooUid, content: 'test reply 1' });
|
||||
const reply2 = await topics.reply({ tid: result.topicData.tid, uid: fooUid, content: 'test reply 2' });
|
||||
const reply3 = await topics.reply({ tid: result.topicData.tid, uid: fooUid, content: 'test reply 3' });
|
||||
await posts.upvote(result.postData.pid, adminUid);
|
||||
await posts.upvote(reply1.pid, adminUid);
|
||||
assert.strictEqual(await db.sortedSetScore('topics:votes', result.topicData.tid), 1);
|
||||
assert.strictEqual(await db.sortedSetScore('cid:' + categoryObj.cid + ':tids:votes', result.topicData.tid), 1);
|
||||
const newTopic = await topics.createTopicFromPosts(adminUid, 'Fork test, vote update', [reply1.pid, reply2.pid], result.topicData.tid);
|
||||
|
||||
assert.strictEqual(await db.sortedSetScore('topics:votes', newTopic.tid), 1);
|
||||
assert.strictEqual(await db.sortedSetScore('cid:' + categoryObj.cid + ':tids:votes', newTopic.tid), 1);
|
||||
assert.strictEqual(await topics.getTopicField(newTopic.tid, 'upvotes'), 1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('controller', function () {
|
||||
|
||||
Reference in New Issue
Block a user