diff --git a/db/models/archivedGather.js b/db/models/archivedGather.js index b88160f..48100b0 100644 --- a/db/models/archivedGather.js +++ b/db/models/archivedGather.js @@ -17,6 +17,11 @@ archivedGatherSchema.static({ .sort({createdAt: -1}) .limit(5) .exec(callback); + }, + archive: function (gather, callback) { + this.create({ + gather: gather.toJson() + }, callback); } }); diff --git a/spec/archivedGather.js b/spec/archivedGather.js index 5e745c5..abd00a5 100644 --- a/spec/archivedGather.js +++ b/spec/archivedGather.js @@ -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 => {