Skip to content

Commit 55c9c89

Browse files
Update dependency mongoose to v7 (#763)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
1 parent ad9262d commit 55c9c89

File tree

3 files changed

+35
-878
lines changed

3 files changed

+35
-878
lines changed

packages/casl-mongoose/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@
4141
"license": "MIT",
4242
"peerDependencies": {
4343
"@casl/ability": "^6.3.2",
44-
"mongoose": "^6.0.13"
44+
"mongoose": "^6.0.13 || ^7.0.0"
4545
},
4646
"devDependencies": {
4747
"@casl/ability": "^6.0.0",
4848
"@casl/dx": "workspace:^1.0.0",
4949
"@types/jest": "^29.0.0",
5050
"chai": "^4.1.0",
5151
"chai-spies": "^1.0.0",
52-
"mongoose": "^6.7.0"
52+
"mongoose": "^7.0.0"
5353
},
5454
"files": [
5555
"dist",

packages/casl-mongoose/spec/accessible_records.spec.ts

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,6 @@ describe('Accessible Records Plugin', () => {
132132
})
133133
})
134134

135-
it('throws `ForbiddenError` when callback is passed to `exec`', async () => {
136-
await wrapInPromise(cb => query.exec(cb))
137-
.then(() => fail('should not execute'))
138-
.catch((error: any) => {
139-
expect(error).toBeInstanceOf(ForbiddenError)
140-
expect(error.message).toMatch(/cannot execute/i)
141-
})
142-
})
143-
144135
it('throws `ForbiddenError` for item request', async () => {
145136
await query.findOne().exec()
146137
.then(() => fail('should not execute'))
@@ -159,15 +150,6 @@ describe('Accessible Records Plugin', () => {
159150
})
160151
})
161152

162-
it('throws `ForbiddenError` for item request when callback is passed to `exec`', async () => {
163-
await wrapInPromise(cb => query.findOne().exec(cb))
164-
.then(() => fail('should not execute'))
165-
.catch((error: any) => {
166-
expect(error).toBeInstanceOf(ForbiddenError)
167-
expect(error.message).toMatch(/cannot execute/i)
168-
})
169-
})
170-
171153
it('throws `ForbiddenError` for count request', async () => {
172154
await query.count()
173155
.then(() => fail('should not execute'))
@@ -208,7 +190,7 @@ describe('Accessible Records Plugin', () => {
208190
const anotherAbility = createMongoAbility([
209191
{ action: 'read', subject: Post }
210192
], {
211-
detectSubjectType: o => o.constructor,
193+
detectSubjectType: o => o.constructor as SubjectType,
212194
})
213195

214196
await Post.find().accessibleBy(anotherAbility, 'update')
@@ -220,11 +202,4 @@ describe('Accessible Records Plugin', () => {
220202
})
221203
})
222204
})
223-
224-
type Callback = (err: mongoose.CallbackError, result: unknown) => void
225-
function wrapInPromise(callback: (fn: Callback) => void) {
226-
return new Promise((resolve, reject) => {
227-
callback((error, result) => error ? reject(error) : resolve(result))
228-
})
229-
}
230205
})

0 commit comments

Comments
 (0)