fix: Incorrect policies returned from documents.update (#7111)
* fix: Incorrect policies returned from documents.update * Regression test
This commit is contained in:
@@ -3316,13 +3316,14 @@ describe("#documents.update", () => {
|
|||||||
body: {
|
body: {
|
||||||
token: user.getJwtToken(),
|
token: user.getJwtToken(),
|
||||||
id: document.id,
|
id: document.id,
|
||||||
text: "Changed text",
|
title: "Changed text",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const body = await res.json();
|
const body = await res.json();
|
||||||
expect(res.status).toEqual(200);
|
expect(res.status).toEqual(200);
|
||||||
expect(body.data.text).toBe("Changed text");
|
expect(body.data.title).toBe("Changed text");
|
||||||
expect(body.data.updatedBy.id).toBe(user.id);
|
expect(body.data.updatedBy.id).toBe(user.id);
|
||||||
|
expect(body.policies[0].abilities.update).toEqual(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not allow editing by read-only collection user", async () => {
|
it("does not allow editing by read-only collection user", async () => {
|
||||||
|
|||||||
@@ -996,7 +996,7 @@ router.post(
|
|||||||
const { user } = ctx.state.auth;
|
const { user } = ctx.state.auth;
|
||||||
let collection: Collection | null | undefined;
|
let collection: Collection | null | undefined;
|
||||||
|
|
||||||
const document = await Document.findByPk(id, {
|
let document = await Document.findByPk(id, {
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
includeState: true,
|
includeState: true,
|
||||||
transaction,
|
transaction,
|
||||||
@@ -1037,7 +1037,7 @@ router.post(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await documentUpdater({
|
document = await documentUpdater({
|
||||||
document,
|
document,
|
||||||
user,
|
user,
|
||||||
...input,
|
...input,
|
||||||
|
|||||||
Reference in New Issue
Block a user