fix: don't crash in flags.validate if user blocked target

This commit is contained in:
Barış Soner Uşaklı
2018-12-09 15:25:43 -05:00
parent 5b41969816
commit 81aa3a0b8a
2 changed files with 53 additions and 8 deletions

View File

@@ -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 () {