mirror of
https://github.com/vale981/grapher
synced 2025-03-05 09:31:42 -05:00
fixed a previous bug, written a test for it
This commit is contained in:
parent
01f86f1f48
commit
52de82ed6f
2 changed files with 6 additions and 1 deletions
|
@ -52,7 +52,7 @@ function cleanOptions(options, restrictedFields) {
|
|||
if (options.fields) {
|
||||
cleanObject(options.fields, restrictedFields);
|
||||
|
||||
if (_.keys(options.fields) === 0) {
|
||||
if (_.keys(options.fields).length === 0) {
|
||||
_.extend(options.fields, {_id: 1})
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -86,6 +86,11 @@ describe('Unit Tests', function () {
|
|||
assert.isDefined(filters.$or[0].$and[0].test);
|
||||
assert.isUndefined(filters.$or[0].$and[0].shouldRestrict);
|
||||
assert.isUndefined(filters.$or[0].$and[0]['shouldRestrict.this']);
|
||||
|
||||
let options2 = {fields: {test: 1}};
|
||||
restrictFields({}, options2, ['test']);
|
||||
assert.isUndefined(options2.fields.test);
|
||||
assert.isDefined(options2.fields._id);
|
||||
});
|
||||
|
||||
it('Should restrict links # getLinks', function () {
|
||||
|
|
Loading…
Add table
Reference in a new issue