mirror of
https://github.com/outline/outline.git
synced 2026-06-13 03:14:59 +03:00
Add locking to collection.move mutation
Add removeIndexCollision tests
This commit is contained in:
@@ -875,6 +875,7 @@ router.post(
|
||||
|
||||
const collection = await Collection.findByPk(id, {
|
||||
transaction,
|
||||
lock: transaction.LOCK.UPDATE,
|
||||
});
|
||||
authorize(user, "move", collection);
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { buildCollection } from "@server/test/factories";
|
||||
import removeIndexCollision from "./removeIndexCollision";
|
||||
|
||||
describe("removeIndexCollision", () => {
|
||||
it("should return the next available index", async () => {
|
||||
const collection = await buildCollection({ index: "P" });
|
||||
expect(
|
||||
await removeIndexCollision(collection.teamId, collection.index!)
|
||||
).toEqual("h");
|
||||
});
|
||||
|
||||
it("should return existing index if no collision", async () => {
|
||||
const collection = await buildCollection({ index: "%P" });
|
||||
expect(await removeIndexCollision(collection.teamId, "n")).toEqual("n");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user