Prevents accidental overwriting of another users work

This commit is contained in:
Tom Moor
2017-11-25 13:04:54 -08:00
parent 7945abbe54
commit 98f317c74a
6 changed files with 36 additions and 2 deletions

View File

@ -277,6 +277,7 @@ describe('#documents.update', async () => {
id: document.id,
title: 'Updated title',
text: 'Updated text',
lastRevision: document.revision,
},
});
const body = await res.json();
@ -287,6 +288,23 @@ describe('#documents.update', async () => {
expect(body.data.collection.documents[1].title).toBe('Updated title');
});
it('should fail if document lastRevision does not match', async () => {
const { user, document } = await seed();
const res = await server.post('/api/documents.update', {
body: {
token: user.getJwtToken(),
id: document.id,
text: 'Updated text',
lastRevision: 123,
},
});
const body = await res.json();
expect(res.status).toEqual(400);
expect(body).toMatchSnapshot();
});
it('should update document details for children', async () => {
const { user, document, collection } = await seed();
collection.documentStructure = [