Skip to content

Commit

Permalink
HotFix: 시니어 정보 수정 시 전화번호를 수정하지 않고 다른 필드를 수정하면 전화번호 중복 오류가 뜨는 문제 해결 (#183
Browse files Browse the repository at this point in the history
)

fix: 시니어 정보 수정 시 전화번호를 수정하지 않고 다른 필드를 수정하면 전화번호 중복 오류가 뜨는 문제 해결
GitJIHO authored Nov 7, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 06a6e43 commit da72e89
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -90,7 +90,8 @@ public void updateSenior(Long memberId, Long seniorId, SeniorRequest seniorReque
() -> new NotFoundException("이메일에 해당하는 시니어를 찾을 수 없습니다.")
);

if(seniorRepository.existsByPhoneNumber(seniorRequest.seniorPhoneNumber())) {
if(!senior.getPhoneNumber().equals(seniorRequest.seniorPhoneNumber())
&& seniorRepository.existsByPhoneNumber(seniorRequest.seniorPhoneNumber())) {
throw new BadRequestException("이미 등록되어 있는 전화번호 입니다.");
}

Original file line number Diff line number Diff line change
@@ -184,6 +184,7 @@ void updateSeniorTest() {
SeniorRequest request = new SeniorRequest("newSeniorName", "01011111111");

when(seniorRepository.findByIdAndMemberId(seniorId, memberId)).thenReturn(Optional.of(senior));
when(senior.getPhoneNumber()).thenReturn("01012121212");
//when
guardService.updateSenior(memberId, seniorId, request);

@@ -203,6 +204,7 @@ void updateSeniorTestFailWhenDuplicatedPhoneNumber() {

when(seniorRepository.findByIdAndMemberId(seniorId, memberId)).thenReturn(Optional.of(senior));
when(seniorRepository.existsByPhoneNumber("01011111111")).thenReturn(true);
when(senior.getPhoneNumber()).thenReturn("01012121212");
//when then
assertThrows(BadRequestException.class, () -> guardService.updateSenior(memberId, seniorId, request));
}

0 comments on commit da72e89

Please sign in to comment.