mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-20 15:30:39 +01:00
fix: don't crash in flags.validate if user blocked target
This commit is contained in:
@@ -401,6 +401,43 @@ describe('Flags', function () {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should not error if user blocked target', function (done) {
|
||||
var SocketFlags = require('../src/socket.io/flags.js');
|
||||
var reporterUid;
|
||||
var reporteeUid;
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
User.create({ username: 'reporter' }, next);
|
||||
},
|
||||
function (uid, next) {
|
||||
reporterUid = uid;
|
||||
User.create({ username: 'reportee' }, next);
|
||||
},
|
||||
function (uid, next) {
|
||||
reporteeUid = uid;
|
||||
User.blocks.add(reporteeUid, reporterUid, next);
|
||||
},
|
||||
function (next) {
|
||||
Topics.post({
|
||||
cid: 1,
|
||||
uid: reporteeUid,
|
||||
title: 'Another topic',
|
||||
content: 'This is flaggable content',
|
||||
}, next);
|
||||
},
|
||||
function (data, next) {
|
||||
SocketFlags.create({ uid: reporterUid }, { type: 'post', id: data.postData.pid, reason: 'spam' }, next);
|
||||
},
|
||||
], done);
|
||||
});
|
||||
|
||||
it('should send back error if reporter does not exist', function (done) {
|
||||
Flags.validate({ uid: 123123123, id: 1, type: 'post' }, function (err) {
|
||||
assert.equal(err.message, '[[error:no-user]]');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('.appendNote()', function () {
|
||||
|
||||
Reference in New Issue
Block a user