Added test case for #238: password hashing before save

This commit is contained in:
Anatoliy Chakkaev 2013-03-27 00:49:02 +04:00
parent de28603460
commit 0d5f4a9aad
1 changed files with 20 additions and 0 deletions

View File

@ -110,6 +110,26 @@ describe('hooks', function() {
user.save();
});
});
it('should save actual modifications to database', function(done) {
User.beforeSave = function(next, data) {
data.password = 'hash';
next();
};
User.destroyAll(function() {
User.create({
email: 'james.bond@example.com',
password: 'secret'
}, function() {
User.findOne({
where: {email: 'james.bond@example.com'}
}, function(err, jb) {
jb.password.should.equal('hash');
done();
});
});
});
});
});
describe('update', function() {