From d25a9d56dcb566c4847cdeeba530d4f7acfecbed Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Fri, 12 Jun 2020 00:18:38 -0700 Subject: [PATCH] fix: updatedBy incorrect in documents.update response --- server/api/documents.js | 1 + server/api/documents.test.js | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/server/api/documents.js b/server/api/documents.js index 4d7518c5..034ce0b3 100644 --- a/server/api/documents.js +++ b/server/api/documents.js @@ -864,6 +864,7 @@ router.post('documents.update', auth(), async ctx => { }); } + document.updatedBy = user; document.collection = collection; ctx.body = { diff --git a/server/api/documents.test.js b/server/api/documents.test.js index 36a10d45..8d653c9c 100644 --- a/server/api/documents.test.js +++ b/server/api/documents.test.js @@ -1410,20 +1410,20 @@ describe('#documents.update', async () => { }); it('allows editing by read-write collection user', async () => { - const { user, document, collection } = await seed(); + const { admin, document, collection } = await seed(); collection.private = true; await collection.save(); await CollectionUser.create({ collectionId: collection.id, - userId: user.id, - createdById: user.id, + userId: admin.id, + createdById: admin.id, permission: 'read_write', }); const res = await server.post('/api/documents.update', { body: { - token: user.getJwtToken(), + token: admin.getJwtToken(), id: document.id, text: 'Changed text', lastRevision: document.revision, @@ -1434,6 +1434,7 @@ describe('#documents.update', async () => { expect(res.status).toEqual(200); expect(body.data.text).toBe('Changed text'); + expect(body.data.updatedBy.id).toBe(admin.id); }); it('does not allow editing by read-only collection user', async () => { @@ -1476,6 +1477,7 @@ describe('#documents.update', async () => { expect(res.status).toEqual(200); expect(body.data.text).toBe(document.text + 'Additional text'); + expect(body.data.updatedBy.id).toBe(user.id); }); it('should require text while appending', async () => {