v1.18.x
Baris Usakli 8 years ago
parent 43a70270ef
commit 18181260e7

@ -28,6 +28,10 @@ module.exports = function (Groups) {
return callback(new Error('[[error:invalid-data]]')); return callback(new Error('[[error:invalid-data]]'));
} }
if (!uid) {
return callback(new Error('[[error:invalid-uid]]'));
}
async.waterfall([ async.waterfall([
function (next) { function (next) {
Groups.isMember(uid, groupName, next); Groups.isMember(uid, groupName, next);

@ -411,6 +411,32 @@ describe('Groups', function () {
}); });
}); });
}); });
it('should fail to add user to group if group name is invalid', function (done) {
Groups.join(0, 1, function (err) {
assert.equal(err.message, '[[error:invalid-data]]');
Groups.join(null, 1, function (err) {
assert.equal(err.message, '[[error:invalid-data]]');
Groups.join(undefined, 1, function (err) {
assert.equal(err.message, '[[error:invalid-data]]');
done();
});
});
});
});
it('should fail to add user to group if uid is invalid', function (done) {
Groups.join('Test', 0, function (err) {
assert.equal(err.message, '[[error:invalid-uid]]');
Groups.join('Test', null, function (err) {
assert.equal(err.message, '[[error:invalid-uid]]');
Groups.join('Test', undefined, function (err) {
assert.equal(err.message, '[[error:invalid-uid]]');
done();
});
});
});
});
}); });
describe('.leave()', function () { describe('.leave()', function () {

Loading…
Cancel
Save