From d668bd564644c13fdc344978b55271a655a3832b Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sun, 7 Apr 2019 09:56:09 -0700 Subject: [PATCH] Remove duplicate save in archive Improve documents.archive test --- server/api/documents.test.js | 4 ++++ server/models/Document.js | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/server/api/documents.test.js b/server/api/documents.test.js index 1feac2f43..1dac998d3 100644 --- a/server/api/documents.test.js +++ b/server/api/documents.test.js @@ -1130,7 +1130,11 @@ describe('#documents.archive', async () => { const res = await server.post('/api/documents.archive', { body: { token: user.getJwtToken(), id: document.id }, }); + const body = await res.json(); + expect(res.status).toEqual(200); + expect(body.data.updatedBy.id).toEqual(user.id); + expect(body.data.archivedAt).toBeTruthy(); }); it('should require authentication', async () => { diff --git a/server/models/Document.js b/server/models/Document.js index dfba75a06..b043b7975 100644 --- a/server/models/Document.js +++ b/server/models/Document.js @@ -20,7 +20,6 @@ const Markdown = new MarkdownSerializer(); const URL_REGEX = /^[a-zA-Z0-9-]*-([a-zA-Z0-9]{10,15})$/; const DEFAULT_TITLE = 'Untitled document'; -// $FlowIssue invalid flow-typed slug.defaults.mode = 'rfc3986'; const slugify = text => slug(text, { @@ -366,9 +365,6 @@ Document.prototype.archive = async function(userId) { await collection.removeDocumentInStructure(this, { save: true }); this.collection = collection; - this.archivedAt = new Date(); - this.lastModifiedById = userId; - await this.save(); await this.archiveWithChildren(userId); events.add({ name: 'documents.archive', model: this });