Added test case for #238: password hashing before save
This commit is contained in:
parent
de28603460
commit
0d5f4a9aad
|
@ -110,6 +110,26 @@ describe('hooks', function() {
|
||||||
user.save();
|
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() {
|
describe('update', function() {
|
||||||
|
|
Loading…
Reference in New Issue