Skip to content

Commit

Permalink
Added test for Instance.update()
Browse files Browse the repository at this point in the history
  • Loading branch information
notheotherben committed Jan 15, 2014
1 parent 34825ac commit bb9a507
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/instance_db.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,31 @@ describe('orm', function () {
});
});
});

describe('update', function() {
it('should retrieve the latest version of the model from the database', function(done) {
model.findOne('billy', function(err, billy1) {
if(err) return done(err);

model.findOne('billy', function(err, billy2) {
if(err) return done(err);

billy1.age++;
billy1.save(function(err) {
if(err) return done(err);
billy2.age.should.eql(billy1.age - 1);

billy2.update(function(err) {
if(err) return done(err);

billy2.age.should.eql(billy1.age);
done();
});
})
});
})
});
});
});
});
});

0 comments on commit bb9a507

Please sign in to comment.