mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-13 21:21:58 +02:00
fix: change owner missing await
This commit is contained in:
@@ -123,7 +123,7 @@ module.exports = function (Posts) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Posts.changeOwner = async function (pids, toUid) {
|
Posts.changeOwner = async function (pids, toUid) {
|
||||||
const exists = user.exists(toUid);
|
const exists = await user.exists(toUid);
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
throw new Error('[[error:no-user]]');
|
throw new Error('[[error:no-user]]');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,6 +134,14 @@ describe('Post\'s', function () {
|
|||||||
assert.strictEqual(await topics.isOwner(postResult.topicData.tid, newUid), true);
|
assert.strictEqual(await topics.isOwner(postResult.topicData.tid, newUid), true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should fail to change owner if new owner does not exist', async function () {
|
||||||
|
try {
|
||||||
|
await posts.changeOwner([1], '9999999');
|
||||||
|
} catch (err) {
|
||||||
|
assert.strictEqual(err.message, '[[error:no-user]]');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
it('should return falsy if post does not exist', function (done) {
|
it('should return falsy if post does not exist', function (done) {
|
||||||
posts.getPostData(9999, function (err, postData) {
|
posts.getPostData(9999, function (err, postData) {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
|
|||||||
Reference in New Issue
Block a user