Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/models/checkpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Checkpoint.current = function(cb) {
var Checkpoint = this;
this.find({
limit: 1,
sort: 'seq DESC'
order: 'seq DESC'
}, function(err, checkpoints) {
if(err) return cb(err);
var checkpoint = checkpoints[0];
Expand Down
24 changes: 24 additions & 0 deletions test/checkpoint.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
var async = require('async');
var loopback = require('../');

// create a unique Checkpoint model
var Checkpoint = require('../lib/models/checkpoint').extend('TestCheckpoint');
Checkpoint.attachTo(loopback.memory());

describe('Checkpoint', function() {
describe('current()', function() {
it('returns the highest `seq` value', function(done) {
async.series([
Checkpoint.create.bind(Checkpoint),
Checkpoint.create.bind(Checkpoint),
function(next) {
Checkpoint.current(function(err, seq) {
if (err) next(err);
expect(seq).to.equal(2);
next();
});
}
], done);
});
});
});