fix: enforce one active logical album grant
This commit is contained in:
1 parent
74ab2eb85f
commit
c400167b8f
9 files changed
+577
-45
No files matched your search
@@ -301,13 +301,13 @@ test("0002 preserves dirty rows and reconstructs only provable legacy intents",
|
||||
"insert into album_grants (editorial_account_id, immich_album_id) values ($1, $2)",
|
||||
[editorialId, "new-invalid-album"],
|
||||
),
|
||||
).rejects.toThrow(/album_grants_canonical_immich_album_id_check/);
|
||||
).rejects.toThrow(/album_grants_immich_album_id_uuid_check/);
|
||||
await expect(
|
||||
testDb.pool.query(
|
||||
"update album_grants set revoked_at = now() where immich_album_id = $1",
|
||||
[dirtyAlbumId],
|
||||
),
|
||||
).rejects.toThrow(/album_grants_canonical_immich_album_id_check/);
|
||||
).rejects.toThrow(/album_grants_immich_album_id_uuid_check/);
|
||||
|
||||
const grantService = createAlbumGrantService({
|
||||
repository: createAlbumGrantRepository(testDb.database),
|
||||
@@ -336,7 +336,9 @@ test("0002 preserves dirty rows and reconstructs only provable legacy intents",
|
||||
[validAlbumId],
|
||||
);
|
||||
expect(canonicalGrantRows.rows).toHaveLength(2);
|
||||
expect(canonicalGrantRows.rows.every((row) => row.immich_album_id === validAlbumId)).toBe(true);
|
||||
expect(canonicalGrantRows.rows.map((row) => row.immich_album_id).sort()).toEqual(
|
||||
[validAlbumId.toUpperCase(), validAlbumId].sort(),
|
||||
);
|
||||
expect(canonicalGrantRows.rows.every((row) => row.revoked_at !== null)).toBe(true);
|
||||
|
||||
await grantService.grantAlbum({
|
||||
|
||||
Reference in new issue
Block a user