Merge pull request #267 from fabien/fix/tiny

Fix error messages, should be lowercase
This commit is contained in:
Raymond Feng 2014-08-31 08:27:15 -07:00
commit 1440b800da
4 changed files with 12 additions and 5 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

@ -1853,7 +1853,7 @@ RelationDefinition.embedsMany = function embedsMany(modelFrom, modelTo, params)
return ids.indexOf(id) === pos;
});
if (ids.length !== uniqueIds.length) {
this.errors.add(propertyName, 'Contains duplicate `' + idName + '`', 'uniqueness');
this.errors.add(propertyName, 'contains duplicate `' + idName + '`', 'uniqueness');
err(false);
}
}, { code: 'uniqueness' })
@ -1877,7 +1877,7 @@ RelationDefinition.embedsMany = function embedsMany(modelFrom, modelTo, params)
}
} else {
hasErrors = true;
self.errors.add(propertyName, 'Contains invalid item', 'invalid');
self.errors.add(propertyName, 'contains invalid item', 'invalid');
}
});
if (hasErrors) err(false);
@ -2325,7 +2325,7 @@ RelationDefinition.referencesMany = function referencesMany(modelFrom, modelTo,
return ids.indexOf(id) === pos;
});
if (ids.length !== uniqueIds.length) {
var msg = 'Contains duplicate `' + modelTo.modelName + '` instance';
var msg = 'contains duplicate `' + modelTo.modelName + '` instance';
this.errors.add(relationName, msg, 'uniqueness');
err(false);
}

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();
});

View File

@ -2411,7 +2411,7 @@ describe('relations', function () {
err.name.should.equal('ValidationError');
err.details.codes.jobs.should.eql(['uniqueness']);
var expected = 'The `Category` instance is not valid. ';
expected += 'Details: `jobs` Contains duplicate `Job` instance.';
expected += 'Details: `jobs` contains duplicate `Job` instance.';
err.message.should.equal(expected);
done();
});