Remove duplicate save in archive
Improve documents.archive test
This commit is contained in:
@ -1130,7 +1130,11 @@ describe('#documents.archive', async () => {
|
|||||||
const res = await server.post('/api/documents.archive', {
|
const res = await server.post('/api/documents.archive', {
|
||||||
body: { token: user.getJwtToken(), id: document.id },
|
body: { token: user.getJwtToken(), id: document.id },
|
||||||
});
|
});
|
||||||
|
const body = await res.json();
|
||||||
|
|
||||||
expect(res.status).toEqual(200);
|
expect(res.status).toEqual(200);
|
||||||
|
expect(body.data.updatedBy.id).toEqual(user.id);
|
||||||
|
expect(body.data.archivedAt).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should require authentication', async () => {
|
it('should require authentication', async () => {
|
||||||
|
@ -20,7 +20,6 @@ const Markdown = new MarkdownSerializer();
|
|||||||
const URL_REGEX = /^[a-zA-Z0-9-]*-([a-zA-Z0-9]{10,15})$/;
|
const URL_REGEX = /^[a-zA-Z0-9-]*-([a-zA-Z0-9]{10,15})$/;
|
||||||
const DEFAULT_TITLE = 'Untitled document';
|
const DEFAULT_TITLE = 'Untitled document';
|
||||||
|
|
||||||
// $FlowIssue invalid flow-typed
|
|
||||||
slug.defaults.mode = 'rfc3986';
|
slug.defaults.mode = 'rfc3986';
|
||||||
const slugify = text =>
|
const slugify = text =>
|
||||||
slug(text, {
|
slug(text, {
|
||||||
@ -366,9 +365,6 @@ Document.prototype.archive = async function(userId) {
|
|||||||
await collection.removeDocumentInStructure(this, { save: true });
|
await collection.removeDocumentInStructure(this, { save: true });
|
||||||
this.collection = collection;
|
this.collection = collection;
|
||||||
|
|
||||||
this.archivedAt = new Date();
|
|
||||||
this.lastModifiedById = userId;
|
|
||||||
await this.save();
|
|
||||||
await this.archiveWithChildren(userId);
|
await this.archiveWithChildren(userId);
|
||||||
|
|
||||||
events.add({ name: 'documents.archive', model: this });
|
events.add({ name: 'documents.archive', model: this });
|
||||||
|
Reference in New Issue
Block a user