From 18d892398f1c9c89ef0672d5ca3d6c006efda769 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Sat, 13 Jun 2020 13:55:48 -0400 Subject: [PATCH] fix: add timestamp to initial username history --- src/user/create.js | 2 +- test/user.js | 17 ++++++----------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/user/create.js b/src/user/create.js index 2edc676c33..a25595ba5f 100644 --- a/src/user/create.js +++ b/src/user/create.js @@ -55,7 +55,7 @@ module.exports = function (User) { const bulkAdd = [ ['username:uid', userData.uid, userData.username], - ['user:' + userData.uid + ':usernames', timestamp, userData.username], + ['user:' + userData.uid + ':usernames', timestamp, userData.username + ':' + timestamp], ['username:sorted', 0, userData.username.toLowerCase() + ':' + userData.uid], ['userslug:uid', userData.uid, userData.userslug], ['users:joindate', timestamp, userData.uid], diff --git a/test/user.js b/test/user.js index ca4ce837a2..fa0b271404 100644 --- a/test/user.js +++ b/test/user.js @@ -1137,17 +1137,12 @@ describe('User', function () { }); - it('should get history from set', function (done) { - var now = Date.now(); - db.sortedSetAdd('user:' + testUid + ':usernames', now, 'derp:' + now, function (err) { - assert.ifError(err); - User.getHistory('user:' + testUid + ':usernames', function (err, data) { - assert.ifError(err); - assert.equal(data[0].value, 'derp'); - assert.equal(data[0].timestamp, now); - done(); - }); - }); + it('should get history from set', async function () { + const now = Date.now(); + await db.sortedSetAdd('user:' + testUid + ':usernames', now, 'derp:' + now); + const data = await User.getHistory('user:' + testUid + ':usernames'); + assert.equal(data[0].value, 'derp'); + assert.equal(data[0].timestamp, now); }); it('should return the correct ban reason', function (done) {