Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
unit(manager): ensure unattached users cannot be checked
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethTrecy committed Sep 16, 2022
1 parent 35f938a commit 6350443
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion database/managers/helpers/condition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default class Condition<T = any> {
return this
}

isIncludedIn(column: string, value: any[]): Condition {
isIncludedIn(column: string, value: any[]|Literal): Condition {
this.currentCondition[column] = { [Op.in]: value }
return this
}
Expand Down
11 changes: 11 additions & 0 deletions database/managers/role.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ describe("Database Manager: Role read operations", () => {
expect(isTheOnlyRole).toBeFalsy()
})

it("cannot check for unattached user", async() => {
const manager = new Manager()
const model = await new Factory().insertOne()
const otherModel = await new Factory().insertOne()
await new UserFactory().attach(model).insertOne()

const isTheOnlyRole = await manager.isTheOnlyRoleToAnyUser(otherModel.id)

expect(isTheOnlyRole).toBeFalsy()
})

it("can count single model", async() => {
const manager = new Manager()
const model = await new Factory().insertOne()
Expand Down

0 comments on commit 6350443

Please sign in to comment.