fix test on redis

v1.18.x
Barış Soner Uşaklı 8 years ago
parent 8920523e06
commit 6fdad4b002

@ -15,7 +15,7 @@ var db = require('../database');
var userController = require('../controllers/user'); var userController = require('../controllers/user');
var privileges = require('../privileges'); var privileges = require('../privileges');
var SocketUser = {}; var SocketUser = module.exports;
require('./user/profile')(SocketUser); require('./user/profile')(SocketUser);
require('./user/search')(SocketUser); require('./user/search')(SocketUser);
@ -327,7 +327,7 @@ SocketUser.setModerationNote = function (socket, data, callback) {
}, },
function (allowed, next) { function (allowed, next) {
if (allowed) { if (allowed) {
return next(null, allowed); return setImmediate(next, null, allowed);
} }
user.isModeratorOfAnyCategory(socket.uid, next); user.isModeratorOfAnyCategory(socket.uid, next);
@ -346,5 +346,3 @@ SocketUser.setModerationNote = function (socket, data, callback) {
}, },
], callback); ], callback);
}; };
module.exports = SocketUser;

@ -975,24 +975,33 @@ describe('User', function () {
}); });
it('should set moderation note', function (done) { it('should set moderation note', function (done) {
User.create({ username: 'noteadmin' }, function (err, adminUid) { var adminUid;
async.waterfall([
function (next) {
User.create({ username: 'noteadmin' }, next);
},
function (_adminUid, next) {
adminUid = _adminUid;
groups.join('administrators', adminUid, next);
},
function (next) {
socketUser.setModerationNote({ uid: adminUid }, { uid: testUid, note: 'this is a test user' }, next);
},
function (next) {
setTimeout(next, 50);
},
function (next) {
socketUser.setModerationNote({ uid: adminUid }, { uid: testUid, note: 'second moderation note' }, next);
},
function (next) {
User.getModerationNotes(testUid, 0, -1, next);
},
], function (err, notes) {
assert.ifError(err); assert.ifError(err);
groups.join('administrators', adminUid, function (err) { assert.equal(notes[0].note, 'second moderation note');
assert.ifError(err); assert.equal(notes[0].uid, adminUid);
socketUser.setModerationNote({ uid: adminUid }, { uid: testUid, note: 'this is a test user' }, function (err) { assert(notes[0].timestamp);
assert.ifError(err); done();
socketUser.setModerationNote({ uid: adminUid }, { uid: testUid, note: 'second moderation note' }, function (err) {
assert.ifError(err);
User.getModerationNotes(testUid, 0, -1, function (err, notes) {
assert.ifError(err);
assert.equal(notes[0].note, 'second moderation note');
assert.equal(notes[0].uid, adminUid);
assert(notes[0].timestamp);
done();
});
});
});
});
}); });
}); });
}); });

Loading…
Cancel
Save