Archive using gather instance

This commit is contained in:
Chris Blanchard 2015-09-26 12:16:39 +01:00
parent a01a3e0216
commit 7f347e26cd
2 changed files with 18 additions and 0 deletions

View file

@ -17,6 +17,11 @@ archivedGatherSchema.static({
.sort({createdAt: -1})
.limit(5)
.exec(callback);
},
archive: function (gather, callback) {
this.create({
gather: gather.toJson()
}, callback);
}
});

View file

@ -70,6 +70,19 @@ describe("ArchivedGather", () => {
});
});
describe(".archive", () => {
it ("archives a gather instance", done => {
ArchivedGather.archive(gather, (error, result) => {
if (error) return done(error);
assert.isDefined(result.createdAt);
let gather = result.gather;
assert.equal(gather.gatherers.length, 12);
assert.equal(gather.state, "done");
done();
});
});
});
describe(".recent", () => {
var gathers;
beforeEach(done => {