mirror of
https://github.com/outline/outline.git
synced 2026-11-25 23:24:06 +03:00
tests
This commit is contained in:
1 parent
6caa2f74ba
commit
bb83dacd17
2 files changed
+23
-2
No files matched your search
@@ -1,10 +1,11 @@
|
||||
import { User, Revision } from "@server/models";
|
||||
import { allow } from "./cancan";
|
||||
import { and, isTeamAdmin, isTeamMutable, or } from "./utils";
|
||||
import { and, isTeamMutable, or } from "./utils";
|
||||
|
||||
allow(User, ["update"], Revision, (actor, revision) =>
|
||||
and(
|
||||
or(actor.id === revision?.userId, isTeamAdmin(actor, revision)),
|
||||
//
|
||||
or(actor.id === revision?.userId, actor.isAdmin),
|
||||
isTeamMutable(actor)
|
||||
)
|
||||
);
|
||||
@@ -1,5 +1,6 @@
|
||||
import { UserMembership, Revision } from "@server/models";
|
||||
import {
|
||||
buildAdmin,
|
||||
buildCollection,
|
||||
buildDocument,
|
||||
buildUser,
|
||||
@@ -63,6 +64,25 @@ describe("#revisions.update", () => {
|
||||
expect(body.data.name).toEqual("new name");
|
||||
});
|
||||
|
||||
it("should allow an admin to update a document revision", async () => {
|
||||
const admin = await buildAdmin();
|
||||
const document = await buildDocument({
|
||||
teamId: admin.teamId,
|
||||
});
|
||||
const revision = await Revision.createFromDocument(document);
|
||||
|
||||
const res = await server.post("/api/revisions.update", {
|
||||
body: {
|
||||
token: admin.getJwtToken(),
|
||||
id: revision.id,
|
||||
name: "new name",
|
||||
},
|
||||
});
|
||||
const body = await res.json();
|
||||
expect(res.status).toEqual(200);
|
||||
expect(body.data.name).toEqual("new name");
|
||||
});
|
||||
|
||||
it("should require authorization", async () => {
|
||||
const document = await buildDocument();
|
||||
const revision = await Revision.createFromDocument(document);
|
||||
|
||||
Reference in new issue
Block a user