Reset json when building model definition

This commit is contained in:
Fabien Franzen 2014-08-31 12:17:53 +02:00
parent 170dc661f4
commit 3f517a4c0a
2 changed files with 8 additions and 1 deletions

View File

@ -210,6 +210,7 @@ ModelDefinition.prototype.build = function (forceRebuild) {
this.properties = null;
this.relations = [];
this._ids = null;
this.json = null;
}
if (this.properties) {
return this.properties;

View File

@ -55,6 +55,8 @@ describe('ModelDefinition class', function () {
});
User.build();
var json = User.toJSON();
User.defineProperty("id", {type: "number", id: true});
assert.equal(User.properties.name.type, String);
@ -62,8 +64,12 @@ describe('ModelDefinition class', function () {
assert.equal(User.properties.approved.type, Boolean);
assert.equal(User.properties.joinedAt.type, Date);
assert.equal(User.properties.age.type, Number);
assert.equal(User.properties.id.type, Number);
json = User.toJSON();
assert.deepEqual(json.properties.id, {type: 'Number', id: true});
done();
});