Skip to content

Commit

Permalink
fix: 방 수정에서 루틴 수정 제외 (#217)
Browse files Browse the repository at this point in the history
  • Loading branch information
ymkim97 authored Dec 1, 2023
1 parent ae751fb commit 6eec958
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,6 @@ public void modifyRoom(Long memberId, Long roomId, ModifyRoomRequest modifyRoomR
room.changePassword(modifyRoomRequest.password());
room.changeCertifyTime(modifyRoomRequest.certifyTime());
room.changeMaxCount(modifyRoomRequest.maxUserCount());

List<Routine> routines = routineRepository.findAllByRoomId(roomId);
routineRepository.deleteAll(routines);

List<Routine> newRoutines = RoutineMapper.toRoutineEntities(room, modifyRoomRequest.routines());
routineRepository.saveAll(newRoutines);
}

@Transactional
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/com/moabam/api/dto/room/ModifyRoomRequest.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
package com.moabam.api.dto.room;

import java.util.List;

import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;

public record ModifyRoomRequest(
@NotBlank @Length(max = 20) String title,
@Length(max = 100, message = "방 공지의 길이 100자 이하여야 합니다.") String announcement,
@NotNull @Size(min = 1, max = 4) List<String> routines,
@Pattern(regexp = "^(|\\d{4,8})$") String password,
@Range(min = 0, max = 23) int certifyTime,
@Range(min = 0, max = 10) int maxUserCount
Expand Down
12 changes: 2 additions & 10 deletions src/test/java/com/moabam/api/presentation/RoomControllerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -299,15 +299,11 @@ void modify_room_success() throws Exception {
Participant participant = RoomFixture.participant(room, 1L);
participant.enableManager();

List<String> newRoutines = new ArrayList<>();
newRoutines.add("물 마시기");
newRoutines.add("코테 풀기");

roomRepository.save(room);
routineRepository.saveAll(routines);
participantRepository.save(participant);

ModifyRoomRequest modifyRoomRequest = new ModifyRoomRequest("수정할 방임!", "공지공지", newRoutines, "4567", 10, 7);
ModifyRoomRequest modifyRoomRequest = new ModifyRoomRequest("수정할 방임!", "공지공지", "4567", 10, 7);
String json = objectMapper.writeValueAsString(modifyRoomRequest);

// expected
Expand Down Expand Up @@ -343,13 +339,9 @@ void unauthorized_modify_room_fail() throws Exception {

Participant participant = RoomFixture.participant(room, 1L);

List<String> routines = new ArrayList<>();
routines.add("물 마시기");
routines.add("코테 풀기");

roomRepository.save(room);
participantRepository.save(participant);
ModifyRoomRequest modifyRoomRequest = new ModifyRoomRequest("수정할 방임!", "방 공지", routines, "1234", 9, 7);
ModifyRoomRequest modifyRoomRequest = new ModifyRoomRequest("수정할 방임!", "방 공지", "1234", 9, 7);
String json = objectMapper.writeValueAsString(modifyRoomRequest);
String message = "{\"message\":\"방장이 아닌 사용자는 방을 수정할 수 없습니다.\"}";

Expand Down

0 comments on commit 6eec958

Please sign in to comment.