Skip to content

Commit bb9a507

Browse files
committed
Added test for Instance.update()
1 parent 34825ac commit bb9a507

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/instance_db.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,31 @@ describe('orm', function () {
109109
});
110110
});
111111
});
112+
113+
describe('update', function() {
114+
it('should retrieve the latest version of the model from the database', function(done) {
115+
model.findOne('billy', function(err, billy1) {
116+
if(err) return done(err);
117+
118+
model.findOne('billy', function(err, billy2) {
119+
if(err) return done(err);
120+
121+
billy1.age++;
122+
billy1.save(function(err) {
123+
if(err) return done(err);
124+
billy2.age.should.eql(billy1.age - 1);
125+
126+
billy2.update(function(err) {
127+
if(err) return done(err);
128+
129+
billy2.age.should.eql(billy1.age);
130+
done();
131+
});
132+
})
133+
});
134+
})
135+
});
136+
});
112137
});
113138
});
114139
});

0 commit comments

Comments
 (0)