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

@ -56,6 +56,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);
assert.equal(User.properties.bio.type, ModelBuilder.Text);
@ -64,6 +66,10 @@ describe('ModelDefinition class', function () {
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();
});