From 0d5f4a9aad9e8b960d38cf12df1066f401e0b395 Mon Sep 17 00:00:00 2001 From: Anatoliy Chakkaev Date: Wed, 27 Mar 2013 00:49:02 +0400 Subject: [PATCH] Added test case for #238: password hashing before save --- test/hooks.test.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/hooks.test.js b/test/hooks.test.js index 5ded42ee..02a04738 100644 --- a/test/hooks.test.js +++ b/test/hooks.test.js @@ -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() {