Update attribute additional test

This commit is contained in:
Anatoliy Chakkaev 2013-03-27 18:53:46 +04:00
parent e75029ebbf
commit b04a250b63
2 changed files with 26 additions and 0 deletions

View File

@ -33,6 +33,7 @@ describe('basic-querying', function() {
it('should query by id: found', function(done) {
User.create(function(err, u) {
should.not.exist(err);
should.exist(u.id);
User.find(u.id, function(err, u) {
should.exist(u);

View File

@ -132,6 +132,31 @@ describe('hooks', function() {
});
});
});
it('should save actual modifications on updateAttributes', function(done) {
User.beforeSave = function(next, data) {
data.password = 'hash';
next();
};
User.destroyAll(function() {
User.create({
email: 'james.bond@example.com'
}, function(err, u) {
u.updateAttribute('password', 'new password', function(e, u) {
should.not.exist(e);
should.exist(u);
u.password.should.equal('hash');
User.findOne({
where: {email: 'james.bond@example.com'}
}, function(err, jb) {
jb.password.should.equal('hash');
done();
});
});
});
});
});
});
describe('update', function() {