Fix how the array of models is iterated
https://github.com/strongloop/loopback-explorer/issues/49
This commit is contained in:
parent
4757d89f10
commit
282b70e1e4
|
@ -102,8 +102,8 @@ var modelHelper = module.exports = {
|
||||||
generateModelDefinition(rel.modelThrough, out);
|
generateModelDefinition(rel.modelThrough, out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(var rm in referencedModels) {
|
for (var i = 0, n = referencedModels.length; i < n; i++) {
|
||||||
generateModelDefinition(referencedModels[rm], out);
|
generateModelDefinition(referencedModels[i], out);
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
},
|
},
|
||||||
|
|
|
@ -164,6 +164,18 @@ describe('model-helper', function() {
|
||||||
expect(defs).has.property('Model5');
|
expect(defs).has.property('Model5');
|
||||||
expect(defs).has.property('Model6');
|
expect(defs).has.property('Model6');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// https://github.com/strongloop/loopback-explorer/issues/49
|
||||||
|
it('should work if Array class is extended and no related models are found',
|
||||||
|
function() {
|
||||||
|
var Model7 = loopback.createModel('Model7', {street: String});
|
||||||
|
Array.prototype.customFunc = function() {
|
||||||
|
};
|
||||||
|
var defs = modelHelper.generateModelDefinition(Model7, {});
|
||||||
|
expect(defs).has.property('Model7');
|
||||||
|
expect(Object.keys(defs)).has.property('length', 1);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('hidden properties', function() {
|
describe('hidden properties', function() {
|
||||||
|
|
Loading…
Reference in New Issue