Skip to content

Commit

Permalink
hotfix: 닉네임 변경 없이 프로필 수정시 닉네임 중복 제약에 걸리는 오류 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
TaeyeonRoyce committed Mar 24, 2024
1 parent 9418bb8 commit 9a68493
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/main/java/com/baro/member/application/MemberService.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ public GetMemberProfileResult getMyProfile(Long id) {

public void updateProfile(UpdateMemberProfileCommand command) {
Member member = memberRepository.getById(command.id());
validateDuplicatedNickname(command.nickname());
if (member.isOtherNickname(command.nickname())) {
validateDuplicatedNickname(command.nickname());
}
member.updateProfile(command.name(), command.nickname());
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/baro/member/domain/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,8 @@ public boolean isDefaultImage() {
public void updateProfileImage(String profileImageUrl) {
this.profileImageUrl = profileImageUrl;
}

public boolean isOtherNickname(String nickname) {
return !this.nickname.value().equals(nickname);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ void setUp() {
@Test
void 사용자_프로필_수정_닉네임_중복_예외_발생() {
// given
Member savedMember = memberRepository.save(MemberFixture.memberWithNickname("바로닉네임"));
memberRepository.save(MemberFixture.memberWithNickname("바로닉네임"));
Member savedMember = memberRepository.save(MemberFixture.memberWithNickname("이전닉네임"));
UpdateMemberProfileCommand command = new UpdateMemberProfileCommand(
savedMember.getId(),
"바로",
Expand Down

0 comments on commit 9a68493

Please sign in to comment.