mirror of https://github.com/ghostfolio/ghostfolio
3 changed files with 12 additions and 11 deletions
@ -1,4 +1,6 @@ |
|||||
import { SetMetadata } from '@nestjs/common'; |
import { SetMetadata } from '@nestjs/common'; |
||||
export const HAS_PERMISSION_KEY = 'has_permission'; |
export const HAS_PERMISSION_KEY = 'has_permission'; |
||||
export const HasPermission = (permission: string) => |
|
||||
SetMetadata(HAS_PERMISSION_KEY, permission); |
export function HasPermission(permission: string) { |
||||
|
return SetMetadata(HAS_PERMISSION_KEY, permission); |
||||
|
} |
||||
|
@ -1,19 +1,19 @@ |
|||||
import { Test, TestingModule } from '@nestjs/testing'; |
import { Test, TestingModule } from '@nestjs/testing'; |
||||
import { HasPermissionsGuard } from './has-permissions.guard'; |
import { HasPermissionsGuard as HasPermissionGuard } from './has-permission.guard'; |
||||
import { Reflector } from '@nestjs/core'; |
import { Reflector } from '@nestjs/core'; |
||||
import { ExecutionContextHost } from '@nestjs/core/helpers/execution-context-host'; |
import { ExecutionContextHost } from '@nestjs/core/helpers/execution-context-host'; |
||||
import { HttpException } from '@nestjs/common'; |
import { HttpException } from '@nestjs/common'; |
||||
|
|
||||
describe('HasPermissionsGuard', () => { |
describe('HasPermissionGuard', () => { |
||||
let guard: HasPermissionsGuard; |
let guard: HasPermissionGuard; |
||||
let reflector: Reflector; |
let reflector: Reflector; |
||||
|
|
||||
beforeEach(async () => { |
beforeEach(async () => { |
||||
const module: TestingModule = await Test.createTestingModule({ |
const module: TestingModule = await Test.createTestingModule({ |
||||
providers: [HasPermissionsGuard, Reflector] |
providers: [HasPermissionGuard, Reflector] |
||||
}).compile(); |
}).compile(); |
||||
|
|
||||
guard = module.get<HasPermissionsGuard>(HasPermissionsGuard); |
guard = module.get<HasPermissionGuard>(HasPermissionGuard); |
||||
reflector = module.get<Reflector>(Reflector); |
reflector = module.get<Reflector>(Reflector); |
||||
}); |
}); |
||||
|
|
Loading…
Reference in new issue