fix: Error in shares.info endpoint when user originally creating share has been deleted
This commit is contained in:
@ -257,6 +257,28 @@ describe("#shares.info", () => {
|
|||||||
|
|
||||||
expect(res.status).toEqual(200);
|
expect(res.status).toEqual(200);
|
||||||
expect(body.data.id).toBe(share.id);
|
expect(body.data.id).toBe(share.id);
|
||||||
|
expect(body.data.createdBy.id).toBe(user.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should allow reading share creaded by deleted user", async () => {
|
||||||
|
const { user, document } = await seed();
|
||||||
|
const author = await buildUser({ teamId: user.teamId });
|
||||||
|
const share = await buildShare({
|
||||||
|
documentId: document.id,
|
||||||
|
teamId: author.teamId,
|
||||||
|
userId: author.id,
|
||||||
|
});
|
||||||
|
|
||||||
|
await author.destroy();
|
||||||
|
|
||||||
|
const res = await server.post("/api/shares.info", {
|
||||||
|
body: { token: user.getJwtToken(), id: share.id },
|
||||||
|
});
|
||||||
|
const body = await res.json();
|
||||||
|
|
||||||
|
expect(res.status).toEqual(200);
|
||||||
|
expect(body.data.id).toBe(share.id);
|
||||||
|
expect(body.data.createdBy.id).toBe(author.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should allow reading share by documentId", async () => {
|
it("should allow reading share by documentId", async () => {
|
||||||
|
@ -37,7 +37,7 @@ Share.associate = (models) => {
|
|||||||
});
|
});
|
||||||
Share.addScope("defaultScope", {
|
Share.addScope("defaultScope", {
|
||||||
include: [
|
include: [
|
||||||
{ association: "user" },
|
{ association: "user", paranoid: false },
|
||||||
{ association: "document" },
|
{ association: "document" },
|
||||||
{ association: "team" },
|
{ association: "team" },
|
||||||
],
|
],
|
||||||
|
Reference in New Issue
Block a user