不要怂,就是干,撸起袖子干!

Commit d5c66c39 by Jan Aagaard Meier

Merge pull request #1040 from bskari/master

Add default value of 1 to decrement to match increment
2 parents e66c7211 c4b38570
Showing with 28 additions and 0 deletions
...@@ -391,6 +391,10 @@ module.exports = (function() { ...@@ -391,6 +391,10 @@ module.exports = (function() {
}); });
} }
if (count === undefined) {
count = 1;
}
return this.increment(fields, 0 - count); return this.increment(fields, 0 - count);
} }
......
...@@ -290,6 +290,18 @@ describe(Support.getTestDialectTeaser("DAO"), function () { ...@@ -290,6 +290,18 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
}) })
}) })
it('with single field and no value', function(done) {
var self = this
this.User.find(1).complete(function(err, user1) {
user1.increment('aNumber').complete(function() {
self.User.find(1).complete(function(err, user2) {
expect(user2.aNumber).to.be.equal(1)
done()
})
})
})
})
it('should still work right with other concurrent updates', function(done) { it('should still work right with other concurrent updates', function(done) {
var self = this var self = this
this.User.find(1).complete(function (err, user1) { this.User.find(1).complete(function (err, user1) {
...@@ -388,6 +400,18 @@ describe(Support.getTestDialectTeaser("DAO"), function () { ...@@ -388,6 +400,18 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
}) })
}) })
it('with single field and no value', function(done) {
var self = this
this.User.find(1).complete(function(err, user1) {
user1.decrement('aNumber').complete(function() {
self.User.find(1).complete(function(err, user2) {
expect(user2.aNumber).to.be.equal(-1)
done()
})
})
})
})
it('should still work right with other concurrent updates', function(done) { it('should still work right with other concurrent updates', function(done) {
var self = this var self = this
this.User.find(1).complete(function(err, user1) { this.User.find(1).complete(function(err, user1) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!