Skip to content

Commit

Permalink
fix: no skin image 버그 해결 (#168)
Browse files Browse the repository at this point in the history
* fix: 회원 로그인 시 기본 부엉이, 오목눈이 생성 기능 추가 및 테스트 코드 변경

* fix: 테스트 코드 변경

* refacotr: config 수정

* test: @BeforeAll Transaction적용 실패로 인한 merge 테스트 추가

* feat: 서비스 추가

* test: 기본 URL 변경 및 테스트 코드 수정

* style: 중복 코드 제거
  • Loading branch information
parksey authored Nov 28, 2023
1 parent bec5144 commit 448dc45
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@ private void validateNickname(String nickname) {

private Member signUp(Long socialId) {
Member member = MemberMapper.toMember(socialId);
Member savedMember = memberRepository.save(member);
saveMyEgg(savedMember);

return memberRepository.save(member);
return savedMember;
}

private void saveMyEgg(Member member) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/moabam/global/common/util/BaseImageUrl.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class BaseImageUrl {
public static final String DEFAULT_NIGHT_AWAKE_SKIN_URL = "";
public static final String DEFAULT_NIGHT_SLEEP_SKIN_URL = "";

public static final String DEFAULT_MORNING_EGG_URL = "moabam/skins/오목눈이/기본/오목눈이알.png";
public static final String DEFAULT_NIGHT_EGG_URL = "moabam/skins/부엉이/기본/부엉이알.png";
public static final String MEMBER_PROFILE_URL = "moabam/default/기본회원프로필.png";
public static final String DEFAULT_MORNING_EGG_URL = "moabam/skins/omok/default/egg.png";
public static final String DEFAULT_NIGHT_EGG_URL = "moabam/skins/owl/default/egg.png";
public static final String MEMBER_PROFILE_URL = "moabam/default/member-profile.png";
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ void signUp_success() {
given(member.getId()).willReturn(1L);
willReturn(member)
.given(memberRepository).save(any(Member.class));
willReturn(List.of(ItemFixture.morningSantaSkin().build(), ItemFixture.nightMageSkin()))
.given(itemRepository).findAllById(any());

// when
LoginResponse result = memberService.login(authorizationTokenInfoResponse);
Expand Down Expand Up @@ -213,5 +215,4 @@ void modify_success_test(@WithMember AuthMember authMember) {
() -> assertThat(member.getProfileImage()).isEqualTo("/main")
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
import com.moabam.support.fixture.RoomFixture;
import com.moabam.support.fixture.TokenSaveValueFixture;

import jakarta.persistence.EntityManager;

@Transactional
@SpringBootTest
@AutoConfigureMockMvc
Expand Down Expand Up @@ -128,6 +130,9 @@ class MemberControllerTest extends WithoutFilterSupporter {

Member member;

@Autowired
EntityManager entityManager;

@BeforeAll
void allSetUp() {
restTemplateBuilder = new RestTemplateBuilder()
Expand All @@ -143,6 +148,7 @@ void setUp() {
RestTemplate restTemplate = restTemplateBuilder.build();
ReflectionTestUtils.setField(oAuth2AuthorizationServerRequestService, "restTemplate", restTemplate);
mockRestServiceServer = MockRestServiceServer.createServer(restTemplate);
member = entityManager.merge(member);
}

@DisplayName("로그아웃 성공 테스트")
Expand Down Expand Up @@ -270,6 +276,7 @@ void search_my_info_success() throws Exception {

member.changeDefaultSkintUrl(night);
member.changeDefaultSkintUrl(morning);
memberRepository.flush();

// expected
mockMvc.perform(get("/members"))
Expand Down Expand Up @@ -317,6 +324,11 @@ void search_my_info_with_no_badge_success() throws Exception {
Inventory killerInven = InventoryFixture.inventory(member.getId(), killer);
inventoryRepository.saveAll(List.of(nightInven, morningInven, killerInven));

member.changeDefaultSkintUrl(night);
member.changeDefaultSkintUrl(morning);

memberRepository.flush();

// expected
mockMvc.perform(get("/members"))
.andExpect(status().isOk())
Expand Down Expand Up @@ -376,6 +388,10 @@ void search_friend_info_success() throws Exception {
memberRepository.flush();
inventoryRepository.saveAll(List.of(nightInven, morningInven, killerInven));

friend.changeDefaultSkintUrl(morning);
friend.changeDefaultSkintUrl(night);
memberRepository.flush();

// expected
mockMvc.perform(get("/members/{memberId}", friend.getId()))
.andExpect(status().isOk())
Expand Down

0 comments on commit 448dc45

Please sign in to comment.