Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Revert "Revert "Fixes issue when using defineProperties we were passi…

…ng the array of properties instead of the property to the 'property' function""

This reverts commit 87244a5.
  • Loading branch information...
commit ca006bc71ea3f8e01a6dbf2675150f0af1fe8cc9 1 parent c33566e
mde authored
Showing with 45 additions and 1 deletion.
  1. +17 −0 .gitignore
  2. +1 −1  lib/index.js
  3. +27 −0 test/validators.js
View
17 .gitignore
@@ -0,0 +1,17 @@
+v8.log
+*.swp
+*.swo
+auth_info.js
+dist
+.idea/
+tags
+nbproject/
+spec/browser/autogen_suite.js
+node_modules
+tmtags
+*.DS_Store
+examples/*/log/*
+site/log/*
+.log
+npm-debug.log
+doc/
View
2  lib/index.js
@@ -839,7 +839,7 @@ model.ModelDefinitionBase = function (name) {
this.defineProperties = function (obj) {
for (var property in obj) {
- this.property(property, obj[property].type, obj);
+ this.property(property, obj[property].type, obj[property]);
}
}
View
27 test/validators.js
@@ -0,0 +1,27 @@
+var model = require('../lib')
+ , assert = require('assert')
+ , model = require('../lib')
+ , tests;
+
+var ModelWithValidations = function () {
+ this.defineProperties({
+ requiredPropertyAddedByDefineProperties: {type: 'string', required: true},
+ });
+
+ this.property('requiredPropertyAddedByProperty', 'string', { required: true});
+};
+
+ModelWithValidations = model.register('ModelWithValidations', ModelWithValidations);
+
+tests = {
+ 'Required option adds a validatesPresent rule when using defineProperties': function () {
+ assert.ok(model.descriptionRegistry['ModelWithValidations'].properties.
+ requiredPropertyAddedByDefineProperties.validations.present);
+ }
+, 'Required option adds a validatesPresent rule when using property': function () {
+ assert.ok(model.descriptionRegistry['ModelWithValidations'].properties.
+ requiredPropertyAddedByProperty.validations.present);
+ }
+};
+
+module.exports = tests;
Please sign in to comment.
Something went wrong with that request. Please try again.