fix tests, remove dupe exposeUid

v1.18.x
Barış Soner Uşaklı 7 years ago
parent 1e63d32e78
commit beadcd7857

@ -220,6 +220,9 @@ Messaging.getTeaser = function (uid, roomId, callback) {
Messaging.getMessageFields(mids[0], ['fromuid', 'content', 'timestamp'], next); Messaging.getMessageFields(mids[0], ['fromuid', 'content', 'timestamp'], next);
}, },
function (teaser, next) { function (teaser, next) {
if (!teaser) {
return callback();
}
user.blocks.is(teaser.fromuid, uid, function (err, blocked) { user.blocks.is(teaser.fromuid, uid, function (err, blocked) {
if (err || blocked) { if (err || blocked) {
return callback(err); return callback(err);

@ -221,17 +221,6 @@ module.exports = function (middleware) {
} }
}; };
middleware.exposeUid = function (req, res, next) {
if (!req.params.userslug) {
return next();
}
user.getUidByUserslug(req.params.userslug, function (err, uid) {
res.locals.uid = uid;
next(err, uid);
});
};
middleware.handleBlocking = function (req, res, next) { middleware.handleBlocking = function (req, res, next) {
user.blocks.is(res.locals.uid, req.uid, function (err, blocked) { user.blocks.is(res.locals.uid, req.uid, function (err, blocked) {
if (err) { if (err) {

@ -76,7 +76,7 @@ module.exports = function (User) {
property = 'uid'; property = 'uid';
} }
if (!Array.isArray(set) || !(set[0].hasOwnProperty(property) || typeof set[0] === 'number' || typeof set[0] === 'string')) { if (!Array.isArray(set) || !set.length || !(set[0].hasOwnProperty(property) || typeof set[0] === 'number' || typeof set[0] === 'string')) {
return callback(null, set); return callback(null, set);
} }

@ -1783,7 +1783,7 @@ describe('User', function () {
it('should automatically increment corresponding user field', function (done) { it('should automatically increment corresponding user field', function (done) {
db.getObjectField('user:1', 'blocksCount', function (err, count) { db.getObjectField('user:1', 'blocksCount', function (err, count) {
assert.ifError(err); assert.ifError(err);
assert.strictEqual(count, '1'); assert.strictEqual(parseInt(count, 10), 1);
done(); done();
}); });
}); });
@ -1809,7 +1809,7 @@ describe('User', function () {
it('should automatically decrement corresponding user field', function (done) { it('should automatically decrement corresponding user field', function (done) {
db.getObjectField('user:1', 'blocksCount', function (err, count) { db.getObjectField('user:1', 'blocksCount', function (err, count) {
assert.ifError(err); assert.ifError(err);
assert.strictEqual(count, '0'); assert.strictEqual(parseInt(count, 10), 0);
done(); done();
}); });
}); });

Loading…
Cancel
Save