Skip to content

Commit

Permalink
Apply feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ssh24 committed Jul 31, 2017
1 parent 5fe2c6b commit 198ae85
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
3 changes: 0 additions & 3 deletions lib/dao.js
Original file line number Diff line number Diff line change
Expand Up @@ -2698,9 +2698,6 @@ DataAccessObject.updateAll = function(where, data, options, cb) {
}
update = inst.toObject(false);

Model.applyProperties(update, inst);
Model = Model.lookupModel(update);

// validation required
inst.isValid(function(valid) {
if (valid) {
Expand Down
17 changes: 17 additions & 0 deletions test/validations.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,8 @@ describe('validations', function() {
Employee.updateAll({where: {id: 1}}, {name: 'Foo-new'},
function(err, emp) {
should.exist(err);
should.equal(err.statusCode, 422);
should.equal(err.details.messages.age[0], 'can\'t be blank');
done();
});
});
Expand Down Expand Up @@ -476,6 +478,8 @@ describe('validations', function() {
Employee.updateAll({where: {id: 1}}, {name: 'Foo-new', age: 5},
function(err, emp) {
should.exist(err);
should.equal(err.statusCode, 422);
should.equal(err.details.messages.name[0], 'can\'t be set');
done();
});
});
Expand Down Expand Up @@ -722,6 +726,8 @@ describe('validations', function() {
Employee.updateAll({where: {id: 1}}, {name: 'Bar', age: 5},
function(err, emp) {
should.exist(err);
should.equal(err.statusCode, 422);
should.equal(err.details.messages.name[0], 'is not unique');
done();
});
});
Expand Down Expand Up @@ -786,6 +792,8 @@ describe('validations', function() {
Employee.updateAll({where: {id: 1}}, {name: '45foo', age: 5},
function(err, emp) {
should.exist(err);
should.equal(err.statusCode, 422);
should.equal(err.details.messages.name[0], 'is invalid');
done();
});
});
Expand Down Expand Up @@ -882,6 +890,8 @@ describe('validations', function() {
Employee.updateAll({where: {id: 1}}, {age: {someAge: 5}},
function(err, emp) {
should.exist(err);
should.equal(err.statusCode, 422);
should.equal(err.details.messages.age[0], 'is not a number');
done();
});
});
Expand Down Expand Up @@ -988,6 +998,9 @@ describe('validations', function() {
Employee.updateAll({where: {id: 1}}, {name: 'Foo-new2', age: 5},
function(err, emp) {
should.exist(err);
should.equal(err.statusCode, 422);
should.equal(err.details.messages.name[0], 'is not included in ' +
'the list');
done();
});
});
Expand Down Expand Up @@ -1075,6 +1088,8 @@ describe('validations', function() {
Employee.updateAll({where: {id: 1}}, {name: 'Bob', age: 5},
function(err, emp) {
should.exist(err);
should.equal(err.statusCode, 422);
should.equal(err.details.messages.name[0], 'is reserved');
done();
});
});
Expand Down Expand Up @@ -1114,6 +1129,8 @@ describe('validations', function() {
Employee.updateAll({where: {id: 1}}, {name: 'Bob', age: 5},
function(err, emp) {
should.exist(err);
should.equal(err.statusCode, 422);
should.equal(err.details.messages.name[0], 'too short');
done();
});
});
Expand Down

0 comments on commit 198ae85

Please sign in to comment.