File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -623,14 +623,6 @@ export default class ProjectsService {
623623 if ( ! isProject ( wbsNumber ) ) throw new HttpException ( 400 , `${ wbsPipe ( wbsNumber ) } is not a valid project WBS #!` ) ;
624624 const { carNumber, projectNumber, workPackageNumber } = wbsNumber ;
625625
626- const checkAssembly = await prisma . assembly . findUnique ( {
627- where : {
628- name
629- }
630- } ) ;
631-
632- if ( checkAssembly ) throw new HttpException ( 400 , `${ name } already exists as an assembly!` ) ;
633-
634626 const project = await prisma . project . findFirst ( {
635627 where : {
636628 wbsElement : {
@@ -645,6 +637,10 @@ export default class ProjectsService {
645637 if ( ! project ) throw new NotFoundException ( 'Project' , wbsPipe ( wbsNumber ) ) ;
646638 if ( project . wbsElement . dateDeleted ) throw new DeletedException ( 'Project' , project . projectId ) ;
647639
640+ const checkAssembly = await prisma . assembly . findUnique ( { where : { name } } ) ;
641+
642+ if ( checkAssembly ) throw new HttpException ( 400 , `${ name } already exists as an assembly!` ) ;
643+
648644 const { teams, wbsElementId } = project ;
649645
650646 if ( ! isAdmin ( userCreated . role ) && ! isUserPartOfTeams ( teams , userCreated ) )
Original file line number Diff line number Diff line change @@ -301,7 +301,6 @@ describe('Projects', () => {
301301 vi . spyOn ( prisma . project , 'findFirst' ) . mockResolvedValue ( {
302302 wbsElement : { ...prismaProject1 . wbsElement , dateDeleted : new Date ( ) } ,
303303 projectId : prismaProject1 . projectId
304- //teams: justiceLeague
305304 } as any ) ;
306305 await expect (
307306 async ( ) =>
@@ -319,6 +318,10 @@ describe('Projects', () => {
319318 } ) ;
320319
321320 test ( 'createAssembly fails if name is not unique' , async ( ) => {
321+ vi . spyOn ( prisma . project , 'findFirst' ) . mockResolvedValue ( {
322+ wbsElement : { ...prismaProject1 . wbsElement } ,
323+ projectId : prismaProject1 . projectId
324+ } as any ) ;
322325 vi . spyOn ( prisma . assembly , 'findUnique' ) . mockResolvedValue ( { ...prismaAssembly1 , name : 'a1' } ) ;
323326
324327 // no error, no return value
You can’t perform that action at this time.
0 commit comments