mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-03-01 01:21:04 +08:00
Revert "feat: auto select medals and make badges interactive"
This reverts commit 4516f77727.
This commit is contained in:
@@ -83,17 +83,6 @@ public class MedalService {
|
||||
seedUserMedal.setSelected(selected == MedalType.SEED);
|
||||
medals.add(seedUserMedal);
|
||||
|
||||
if (user != null && medals.stream().noneMatch(MedalDto::isSelected)) {
|
||||
medals.stream()
|
||||
.filter(MedalDto::isCompleted)
|
||||
.findFirst()
|
||||
.ifPresent(m -> {
|
||||
m.setSelected(true);
|
||||
user.setDisplayMedal(m.getType());
|
||||
userRepository.save(user);
|
||||
});
|
||||
}
|
||||
|
||||
return medals;
|
||||
}
|
||||
|
||||
|
||||
@@ -92,24 +92,4 @@ class MedalServiceTest {
|
||||
MedalService service = new MedalService(commentRepo, postRepo, userRepo);
|
||||
assertThrows(IllegalArgumentException.class, () -> service.selectMedal("user", MedalType.COMMENT));
|
||||
}
|
||||
|
||||
@Test
|
||||
void autoSelectFirstCompletedMedal() {
|
||||
CommentRepository commentRepo = mock(CommentRepository.class);
|
||||
PostRepository postRepo = mock(PostRepository.class);
|
||||
UserRepository userRepo = mock(UserRepository.class);
|
||||
|
||||
when(commentRepo.countByAuthor_Id(1L)).thenReturn(120L);
|
||||
when(postRepo.countByAuthor_Id(1L)).thenReturn(0L);
|
||||
User user = new User();
|
||||
user.setId(1L);
|
||||
user.setCreatedAt(LocalDateTime.of(2025, 9, 15, 0, 0));
|
||||
when(userRepo.findById(1L)).thenReturn(Optional.of(user));
|
||||
|
||||
MedalService service = new MedalService(commentRepo, postRepo, userRepo);
|
||||
List<MedalDto> medals = service.getMedals(1L);
|
||||
|
||||
assertEquals(MedalType.COMMENT, user.getDisplayMedal());
|
||||
assertTrue(medals.stream().anyMatch(m -> m.getType() == MedalType.COMMENT && m.isSelected()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user