From b04a250b632b5e4ef5bd712c0e5717a8c594bee9 Mon Sep 17 00:00:00 2001 From: Anatoliy Chakkaev Date: Wed, 27 Mar 2013 18:53:46 +0400 Subject: [PATCH] Update attribute additional test --- test/basic-querying.test.js | 1 + test/hooks.test.js | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/test/basic-querying.test.js b/test/basic-querying.test.js index e4a58f6b..5129c5af 100644 --- a/test/basic-querying.test.js +++ b/test/basic-querying.test.js @@ -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); diff --git a/test/hooks.test.js b/test/hooks.test.js index 235b1fcd..47031856 100644 --- a/test/hooks.test.js +++ b/test/hooks.test.js @@ -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() {