add groupTitle test for guests

v1.18.x
Barış Soner Uşaklı 6 years ago
parent 1c981e638b
commit a6864a8055

@ -141,9 +141,6 @@ module.exports = function (User) {
db.parseIntFields(user, intFields, requestedFields);
if (user.hasOwnProperty('groupTitle')) {
parseGroupTitle(user);
}
if (user.hasOwnProperty('username')) {
user.username = validator.escape(user.username ? user.username.toString() : '');
}
@ -155,6 +152,11 @@ module.exports = function (User) {
user.picture = User.getDefaultAvatar();
user['icon:text'] = '?';
user['icon:bgColor'] = '#aaa';
user.groupTitle = '';
}
if (user.hasOwnProperty('groupTitle')) {
parseGroupTitle(user);
}
if (user.picture && user.picture === user.uploadedpicture) {
@ -204,12 +206,20 @@ module.exports = function (User) {
try {
user.groupTitleArray = JSON.parse(user.groupTitle);
} catch (err) {
user.groupTitleArray = [user.groupTitle];
if (user.groupTitle) {
user.groupTitleArray = [user.groupTitle];
} else {
user.groupTitleArray = [];
}
}
if (!Array.isArray(user.groupTitleArray)) {
user.groupTitleArray = [user.groupTitleArray];
if (user.groupTitleArray) {
user.groupTitleArray = [user.groupTitleArray];
} else {
user.groupTitleArray = [];
}
}
if (!meta.config.allowMultipleBadges) {
if (!meta.config.allowMultipleBadges && user.groupTitleArray.length) {
user.groupTitleArray = [user.groupTitleArray[0]];
}
}

@ -605,6 +605,15 @@ describe('User', function () {
done();
});
});
it('should not get groupTitle for guests', function (done) {
User.getUserData(0, function (err, userData) {
assert.ifError(err);
assert.strictEqual(userData.groupTitle, '');
assert.deepStrictEqual(userData.groupTitleArray, []);
done();
});
});
});
describe('not logged in', function () {

Loading…
Cancel
Save