mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 02:55:58 +01:00 
			
		
		
		
	fix test on redis
This commit is contained in:
		| @@ -15,7 +15,7 @@ var db = require('../database'); | ||||
| var userController = require('../controllers/user'); | ||||
| var privileges = require('../privileges'); | ||||
|  | ||||
| var SocketUser = {}; | ||||
| var SocketUser = module.exports; | ||||
|  | ||||
| require('./user/profile')(SocketUser); | ||||
| require('./user/search')(SocketUser); | ||||
| @@ -327,7 +327,7 @@ SocketUser.setModerationNote = function (socket, data, callback) { | ||||
| 		}, | ||||
| 		function (allowed, next) { | ||||
| 			if (allowed) { | ||||
| 				return next(null, allowed); | ||||
| 				return setImmediate(next, null, allowed); | ||||
| 			} | ||||
|  | ||||
| 			user.isModeratorOfAnyCategory(socket.uid, next); | ||||
| @@ -346,5 +346,3 @@ SocketUser.setModerationNote = function (socket, data, callback) { | ||||
| 		}, | ||||
| 	], callback); | ||||
| }; | ||||
|  | ||||
| module.exports = SocketUser; | ||||
|   | ||||
							
								
								
									
										35
									
								
								test/user.js
									
									
									
									
									
								
							
							
						
						
									
										35
									
								
								test/user.js
									
									
									
									
									
								
							| @@ -975,15 +975,28 @@ describe('User', function () { | ||||
| 		}); | ||||
|  | ||||
| 		it('should set moderation note', function (done) { | ||||
| 			User.create({ username: 'noteadmin' }, function (err, adminUid) { | ||||
| 				assert.ifError(err); | ||||
| 				groups.join('administrators', adminUid, function (err) { | ||||
| 					assert.ifError(err); | ||||
| 					socketUser.setModerationNote({ uid: adminUid }, { uid: testUid, note: 'this is a test user' }, function (err) { | ||||
| 						assert.ifError(err); | ||||
| 						socketUser.setModerationNote({ uid: adminUid }, { uid: testUid, note: 'second moderation note' }, function (err) { | ||||
| 							assert.ifError(err); | ||||
| 							User.getModerationNotes(testUid, 0, -1, function (err, notes) { | ||||
| 			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.equal(notes[0].note, 'second moderation note'); | ||||
| 				assert.equal(notes[0].uid, adminUid); | ||||
| @@ -992,10 +1005,6 @@ describe('User', function () { | ||||
| 			}); | ||||
| 		}); | ||||
| 	}); | ||||
| 				}); | ||||
| 			}); | ||||
| 		}); | ||||
| 	}); | ||||
|  | ||||
| 	describe('approval queue', function () { | ||||
| 		var socketAdmin = require('../src/socket.io/admin'); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user