mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
fix: Incorrect policies returned after unpublishing document
Related https://github.com/outline/outline/discussions/7258
This commit is contained in:
@@ -831,7 +831,9 @@ class Document extends ParanoidModel<
|
||||
|
||||
if (collection) {
|
||||
await collection.addDocumentToStructure(this, 0, { transaction });
|
||||
this.collection = collection;
|
||||
if (this.collection) {
|
||||
this.collection.documentStructure = collection.documentStructure;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -899,7 +901,9 @@ class Document extends ParanoidModel<
|
||||
|
||||
if (collection) {
|
||||
await collection.removeDocumentInStructure(this, { transaction });
|
||||
this.collection = collection;
|
||||
if (this.collection) {
|
||||
this.collection.documentStructure = collection.documentStructure;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -926,7 +930,9 @@ class Document extends ParanoidModel<
|
||||
|
||||
if (collection) {
|
||||
await collection.removeDocumentInStructure(this, { transaction });
|
||||
this.collection = collection;
|
||||
if (this.collection) {
|
||||
this.collection.documentStructure = collection.documentStructure;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -961,7 +967,9 @@ class Document extends ParanoidModel<
|
||||
await collection.addDocumentToStructure(this, undefined, {
|
||||
transaction,
|
||||
});
|
||||
this.collection = collection;
|
||||
if (this.collection) {
|
||||
this.collection.documentStructure = collection.documentStructure;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -3803,6 +3803,8 @@ describe("#documents.unpublish", () => {
|
||||
expect(body.data.publishedAt).toBeNull();
|
||||
expect(body.data.createdBy.id).toEqual(user.id);
|
||||
expect(body.data.updatedBy.id).toEqual(user.id);
|
||||
expect(body.policies[0].abilities.createChildDocument).toEqual(false);
|
||||
expect(body.policies[0].abilities.update).toEqual(true);
|
||||
|
||||
const reloaded = await Document.unscoped().findByPk(document.id);
|
||||
expect(reloaded!.createdById).toEqual(user.id);
|
||||
|
||||
Reference in New Issue
Block a user