fix: updatedBy incorrect in documents.update response
This commit is contained in:
@ -864,6 +864,7 @@ router.post('documents.update', auth(), async ctx => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
document.updatedBy = user;
|
||||||
document.collection = collection;
|
document.collection = collection;
|
||||||
|
|
||||||
ctx.body = {
|
ctx.body = {
|
||||||
|
@ -1410,20 +1410,20 @@ describe('#documents.update', async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('allows editing by read-write collection user', 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;
|
collection.private = true;
|
||||||
await collection.save();
|
await collection.save();
|
||||||
|
|
||||||
await CollectionUser.create({
|
await CollectionUser.create({
|
||||||
collectionId: collection.id,
|
collectionId: collection.id,
|
||||||
userId: user.id,
|
userId: admin.id,
|
||||||
createdById: user.id,
|
createdById: admin.id,
|
||||||
permission: 'read_write',
|
permission: 'read_write',
|
||||||
});
|
});
|
||||||
|
|
||||||
const res = await server.post('/api/documents.update', {
|
const res = await server.post('/api/documents.update', {
|
||||||
body: {
|
body: {
|
||||||
token: user.getJwtToken(),
|
token: admin.getJwtToken(),
|
||||||
id: document.id,
|
id: document.id,
|
||||||
text: 'Changed text',
|
text: 'Changed text',
|
||||||
lastRevision: document.revision,
|
lastRevision: document.revision,
|
||||||
@ -1434,6 +1434,7 @@ describe('#documents.update', async () => {
|
|||||||
|
|
||||||
expect(res.status).toEqual(200);
|
expect(res.status).toEqual(200);
|
||||||
expect(body.data.text).toBe('Changed text');
|
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 () => {
|
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(res.status).toEqual(200);
|
||||||
expect(body.data.text).toBe(document.text + 'Additional text');
|
expect(body.data.text).toBe(document.text + 'Additional text');
|
||||||
|
expect(body.data.updatedBy.id).toBe(user.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should require text while appending', async () => {
|
it('should require text while appending', async () => {
|
||||||
|
Reference in New Issue
Block a user