diff --git a/src/main/java/com/moabam/api/application/room/RoomService.java b/src/main/java/com/moabam/api/application/room/RoomService.java index d14228a6..b4a90fcd 100644 --- a/src/main/java/com/moabam/api/application/room/RoomService.java +++ b/src/main/java/com/moabam/api/application/room/RoomService.java @@ -116,6 +116,8 @@ public void exitRoom(Long memberId, Long roomId) { return; } + List routines = routineRepository.findAllByRoomId(roomId); + routineRepository.deleteAll(routines); roomRepository.delete(room); } diff --git a/src/test/java/com/moabam/api/presentation/RoomControllerTest.java b/src/test/java/com/moabam/api/presentation/RoomControllerTest.java index 61170e45..c922bc93 100644 --- a/src/test/java/com/moabam/api/presentation/RoomControllerTest.java +++ b/src/test/java/com/moabam/api/presentation/RoomControllerTest.java @@ -663,10 +663,13 @@ void manager_delete_room_success() throws Exception { .maxUserCount(8) .build(); + List routines = RoomFixture.routines(room); + Participant participant = RoomFixture.participant(room, 1L); participant.enableManager(); roomRepository.save(room); + routineRepository.saveAll(routines); participantRepository.save(participant); // expected @@ -675,9 +678,11 @@ void manager_delete_room_success() throws Exception { .andDo(print()); List deletedRoom = roomRepository.findAll(); + List deletedRoutine = routineRepository.findAll(); List deletedParticipant = participantRepository.findAll(); assertThat(deletedRoom).isEmpty(); + assertThat(deletedRoutine).hasSize(0); assertThat(deletedParticipant).hasSize(1); assertThat(deletedParticipant.get(0).getDeletedAt()).isNotNull(); assertThat(deletedParticipant.get(0).getDeletedRoomTitle()).isNotNull();