-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feat] 카테고리 ADMIN 역할을 포기하더라도 자신이 생성한 카테고리라면 구독 해제가 안되는 문제를 해결한다. #713
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
안녕하세여 후디
간단히 객체 내부로 옮길 수 있는 로직 찾아보았습니다. 찬찬히 살펴보시고 반영해주십쇼
private void validateCategoryType(final CategoryRole categoryRole) { | ||
CategoryType categoryType = categoryRole.getCategory().getCategoryType(); | ||
if (categoryType == PERSONAL || categoryType == GOOGLE) { | ||
throw new NotAbleToChangeRoleException("개인 카테고리 또는 외부 카테고리에 대한 회원의 역할을 변경할 수 없습니다."); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
category 내부로 로직을 이동하는건 어떨까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 그렇네요! 반영하겠습니다.
if (!member.getId().equals(memberId)) { | ||
throw new NoPermissionException("타인의 구독 정보에 접근할 수 없습니다."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이거도 member 쪽으로 위임가능할 것 같네요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
헉 멤버쪽에 hasSameId()
가 있었네요! 변경했습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
안녕하세요 매트! 작성해주신 기능 잘보았어요!!
로직도 깔끔하고 테스트코드도 꼼곰하게 작성해주셔서 변경사항이 보이지 않네요!
바로 approve 하였습니다!
deleteSubscription(id, memberId, subscription); | ||
deleteCategoryRole(memberId, subscription); | ||
} | ||
|
||
private void deleteSubscription(final Long id, final Long memberId, final Subscription subscription) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
불필요한 로직이 제거되었군요!👍👍
@@ -45,7 +45,7 @@ public class ControllerAdvice { | |||
InvalidSubscriptionException.class, | |||
ExistSubscriptionException.class, | |||
ExistExternalCategoryException.class, | |||
NotAbleToMangeRoleException.class | |||
NotAbleToChangeRoleException.class |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
더욱 명확한 네이밍이군요!👍👍
|
||
@DisplayName("개인 카테고리에 대한 회원의 역할을 변경할 경우 예외가 발생한다.") | ||
@Test | ||
void 개인_카테고리에_대한_회원의_역할을_변경할_경우_예외가_발생한다() { | ||
// given | ||
Member 후디 = memberRepository.save(후디()); | ||
CategoryResponse 개인_카테고리 = categoryService.save(후디.getId(), 내_일정_생성_요청); | ||
|
||
// when & then | ||
CategoryRoleUpdateRequest request = new CategoryRoleUpdateRequest(NONE); | ||
assertThatThrownBy(() -> categoryRoleService.updateRole(후디.getId(), 후디.getId(), 개인_카테고리.getId(), request)) | ||
.isInstanceOf(NotAbleToChangeRoleException.class); | ||
} | ||
|
||
@DisplayName("외부 카테고리에 대한 회원의 역할을 변경할 경우 예외가 발생한다.") | ||
@Test | ||
void 외부_카테고리에_대한_회원의_역할을_변경할_경우_예외가_발생한다() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
꼼꼼한 테스트 코드군요!!
@DisplayName("자신이 만든 카테고리에 대한 구독을 삭제할 경우 예외를 던진다") | ||
@Test | ||
void 자신이_만든_카테고리에_대한_구독을_삭제할_경우_예외를_던진다() { | ||
// given | ||
Member 관리자 = memberRepository.save(관리자()); | ||
Category 공통_일정 = categoryRepository.save(공통_일정(관리자)); | ||
Subscription 공통_일정_구독 = subscriptionRepository.save(색상1_구독(관리자, 공통_일정)); | ||
|
||
// when & then | ||
assertThatThrownBy(() -> subscriptionService.delete(공통_일정_구독.getId(), 관리자.getId())) | ||
.isInstanceOf(NoPermissionException.class); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
불필요한 테스트코드가 삭제되었군요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
확인했습니다! 앞에서 매트가 리뷰 잘 해주신 것 같네요 ㅎㅎ 굳굳
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
- NotAbleToManageRoleException 을 NotAbleToChangeRoleException 으로 변경 - 다른 사람의 구독 정보에 접근하는 것을 차단하는 로직이 없어 추가
c885814
to
907a3e5
Compare
[feat] PR을 등록한다.
작업 내용
스크린샷
주의사항
Closes #711