Skip to content

Commit 5c300a0

Browse files
committed
#1522: updated the test that verifies accessDeniedException
1 parent 2877945 commit 5c300a0

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/backend/src/services/projects.services.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import {
99
AccessDeniedGuestException,
1010
HttpException,
1111
NotFoundException,
12-
DeletedException
12+
DeletedException,
13+
AccessDeniedException
1314
} from '../utils/errors.utils';
1415
import {
1516
addDescriptionBullets,
@@ -610,7 +611,8 @@ export default class ProjectsService {
610611
* @throws if the submitter is not a leader or the material type with the given name already exists
611612
*/
612613
static async createMaterialType(name: string, submitter: User): Promise<Material_Type> {
613-
if (!isLeadership(submitter.role)) throw new AccessDeniedAdminOnlyException('create material type');
614+
if (!isLeadership(submitter.role))
615+
throw new AccessDeniedException('Only leadership or above can create a material type');
614616

615617
const materialType = await prisma.material_Type.findUnique({
616618
where: {

src/backend/tests/projects.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import * as projectTransformer from '../src/transformers/projects.transformer';
99
import ProjectsService from '../src/services/projects.services';
1010
import {
1111
AccessDeniedAdminOnlyException,
12+
AccessDeniedException,
1213
DeletedException,
1314
HttpException,
1415
NotFoundException
@@ -258,7 +259,7 @@ describe('Projects', () => {
258259
describe('materialType', () => {
259260
test('Create material type fails if user is not leader', async () => {
260261
await expect(ProjectsService.createMaterialType('Tools', wonderwoman)).rejects.toThrow(
261-
new AccessDeniedAdminOnlyException('create material type')
262+
new AccessDeniedException('Only leadership or above can create a material type')
262263
);
263264
});
264265

0 commit comments

Comments
 (0)