v1.18.x
Julian Lam 8 years ago
parent 5e109bb4a8
commit ebffc44600

@ -47,7 +47,7 @@ Flags.get = function (flagId, callback) {
}; };
Flags.list = function (filters, uid, callback) { Flags.list = function (filters, uid, callback) {
if (typeof filters === 'function' && !callback) { if (typeof filters === 'function' && !uid && !callback) {
callback = filters; callback = filters;
filters = {}; filters = {};
} }

@ -41,6 +41,11 @@ describe('Flags', function () {
}, },
function (uid, next) { function (uid, next) {
Groups.join('administrators', uid, next); Groups.join('administrators', uid, next);
},
function (next) {
User.create({
username: 'unprivileged', password: 'abcdef', email: 'd@e.com'
}, next);
} }
], done); ], done);
}); });
@ -109,6 +114,15 @@ describe('Flags', function () {
}); });
}); });
}); });
it('should return a filtered list of flags if said filters are passed in', function (done) {
Flags.list({
state: 'open'
}, 1, function (err, flags) {
assert.ifError(err);
done();
});
});
}); });
describe('.update()', function () { describe('.update()', function () {
@ -221,7 +235,7 @@ describe('Flags', function () {
Flags.validate({ Flags.validate({
type: 'post', type: 'post',
id: 1, id: 1,
uid: 2 uid: 3
}, function (err) { }, function (err) {
assert.ok(err); assert.ok(err);
assert.strictEqual('[[error:not-enough-reputation-to-flag]]', err.message); assert.strictEqual('[[error:not-enough-reputation-to-flag]]', err.message);
@ -310,7 +324,9 @@ describe('Flags', function () {
}); });
it('should add a new entry into a flag\'s history', function (done) { it('should add a new entry into a flag\'s history', function (done) {
Flags.appendHistory(1, 1, ['state:rejected'], function (err) { Flags.appendHistory(1, 1, {
state: 'rejected'
}, function (err) {
assert.ifError(err); assert.ifError(err);
Flags.getHistory(1, function (err, history) { Flags.getHistory(1, function (err, history) {
@ -329,7 +345,7 @@ describe('Flags', function () {
it('should retrieve a flag\'s history', function (done) { it('should retrieve a flag\'s history', function (done) {
Flags.getHistory(1, function (err, history) { Flags.getHistory(1, function (err, history) {
assert.ifError(err); assert.ifError(err);
assert.strictEqual(history[0].fields[0].value, '[[flags:state-rejected]]'); assert.strictEqual(history[0].fields.state, '[[flags:state-rejected]]');
done(); done();
}); });
}); });

Loading…
Cancel
Save