fix: #9681, update posts in queue if target tid is merged

This commit is contained in:
Barış Soner Uşaklı
2021-07-30 22:51:06 -04:00
parent 03a98f4de4
commit 0c81642997
4 changed files with 52 additions and 10 deletions

View File

@@ -1147,13 +1147,31 @@ describe('Post\'s', () => {
});
});
it('should bypass post queue if user is in exempt group', (done) => {
it('should bypass post queue if user is in exempt group', async () => {
const oldValue = meta.config.groupsExemptFromPostQueue;
meta.config.groupsExemptFromPostQueue = ['registered-users'];
socketTopics.post({ uid: uid, emit: () => {} }, { title: 'should not be queued', content: 'topic content', cid: cid }, (err, result) => {
assert.ifError(err);
assert.strictEqual(result.title, 'should not be queued');
done();
});
const uid = await user.create({ username: 'mergeexemptuser' });
const result = await socketTopics.post({ uid: uid, emit: () => {} }, { title: 'should not be queued', content: 'topic content', cid: cid });
assert.strictEqual(result.title, 'should not be queued');
meta.config.groupsExemptFromPostQueue = oldValue;
});
it('should update queued post\'s topic if target topic is merged', async () => {
const uid = await user.create({ username: 'mergetestsuser' });
const result1 = await socketTopics.post({ uid: globalModUid }, { title: 'topic A', content: 'topic A content', cid: cid });
const result2 = await socketTopics.post({ uid: globalModUid }, { title: 'topic B', content: 'topic B content', cid: cid });
const result = await socketPosts.reply({ uid: uid }, { content: 'the moved queued post', tid: result1.tid });
await topics.merge([
result1.tid, result2.tid,
], globalModUid, { mainTid: result2.tid });
let postData = await posts.getQueuedPosts();
postData = postData.filter(p => p.data.tid === result2.tid);
assert.strictEqual(postData.length, 1);
assert.strictEqual(postData[0].data.content, 'the moved queued post');
assert.strictEqual(postData[0].data.tid, result2.tid);
});
});