diff --git a/src/__tests__/clan/role/ClanRoleService/ClanRoleService.checkVotingOnExpire.test.ts b/src/__tests__/clan/role/ClanRoleService/ClanRoleService.checkVotingOnExpire.test.ts index 0b3ab9c0f..7e22af01a 100644 --- a/src/__tests__/clan/role/ClanRoleService/ClanRoleService.checkVotingOnExpire.test.ts +++ b/src/__tests__/clan/role/ClanRoleService/ClanRoleService.checkVotingOnExpire.test.ts @@ -59,6 +59,9 @@ describe('ClanRoleService.checkVotingOnExpire', () => { // Player should have updated clanRole_id const updatedPlayer = await playerModel.findById(player._id); expect(updatedPlayer.clanRole_id.toString()).toBe(role_id.toString()); + expect((roleService as any).votingService.finalizeVoting).toHaveBeenCalledWith( + votingDto._id, + ); expect(result).toBe(true); expect(errors).toBeNull(); @@ -90,6 +93,9 @@ describe('ClanRoleService.checkVotingOnExpire', () => { // Player should NOT have updated clanRole_id const updatedPlayer = await playerModel.findById(player._id); expect(updatedPlayer.clanRole_id).toEqual(clanRoleId); + expect((roleService as any).votingService.finalizeVoting).toHaveBeenCalledWith( + votingDto._id, + ); expect(result).toBe(true); expect(errors).toBeNull(); diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.ts index ab25b319a..fd217453c 100644 --- a/src/auth/auth.controller.ts +++ b/src/auth/auth.controller.ts @@ -9,6 +9,7 @@ import ApiResponseDescription from '../common/swagger/response/ApiResponseDescri import { ModelName } from '../common/enum/modelName.enum'; import { NoBoxIdFilter } from '../box/auth/decorator/NoBoxIdFilter.decorator'; import { SignInResponseDto } from './dto/signInResponse.dto'; +import { ApiBody } from '@nestjs/swagger'; @NoAuth() @Controller('auth') @@ -25,6 +26,7 @@ export class AuthController { * * If the user provides the correct credentials, the access token will be returned, which should be used as a Bearer token in the Authorization header. */ + @ApiBody({ type: SignInDto }) @ApiResponseDescription({ success: { status: 201, diff --git a/src/clan/role/clanRole.service.ts b/src/clan/role/clanRole.service.ts index 1b77ca402..f709af0a7 100644 --- a/src/clan/role/clanRole.service.ts +++ b/src/clan/role/clanRole.service.ts @@ -474,31 +474,29 @@ export default class ClanRoleService { true, ); - if (!votePassed) { - return [true, null]; - } - - if (!voting.setClanRole?.player_id || !voting.setClanRole?.role_id) { - return [ - null, - [ - new ServiceError({ - reason: SEReason.REQUIRED, - field: 'setClanRole', - value: voting.setClanRole, - message: - 'Voting is missing player_id or role_id for clan role update', - }), - ], - ]; + if (votePassed) { + if (!voting.setClanRole?.player_id || !voting.setClanRole?.role_id) { + return [ + null, + [ + new ServiceError({ + reason: SEReason.REQUIRED, + field: 'setClanRole', + value: voting.setClanRole, + message: + 'Voting is missing player_id or role_id for clan role update', + }), + ], + ]; + } + + const [, updateErrors] = await this.playerBasicService.updateOneById( + voting.setClanRole.player_id.toString(), + { clanRole_id: new ObjectId(voting.setClanRole.role_id.toString()) }, + ); + if (updateErrors) return [null, updateErrors]; } - const [, updateErrors] = await this.playerBasicService.updateOneById( - voting.setClanRole.player_id.toString(), - { clanRole_id: new ObjectId(voting.setClanRole.role_id.toString()) }, - ); - if (updateErrors) return [null, updateErrors]; - await this.votingService.finalizeVoting(voting._id); return [true, null];