mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-25 15:40:49 +08:00
Compare commits
12 Commits
codex/upda
...
pr-971
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6baa4d4233 | ||
|
|
ef9d90455f | ||
|
|
5d499956d7 | ||
|
|
9101ed336c | ||
|
|
28e3ebb911 | ||
|
|
e93e33fe43 | ||
|
|
0ebeccf21e | ||
|
|
89842b82e9 | ||
|
|
58594229f2 | ||
|
|
b4a811ff4e | ||
|
|
7067630bcc | ||
|
|
b28e8d4bc9 |
@@ -97,8 +97,10 @@ public class CachingConfig {
|
|||||||
// 个别缓存单独设置 TTL 时间
|
// 个别缓存单独设置 TTL 时间
|
||||||
Map<String, RedisCacheConfiguration> cacheConfigs = new HashMap<>();
|
Map<String, RedisCacheConfiguration> cacheConfigs = new HashMap<>();
|
||||||
RedisCacheConfiguration oneHourConfig = config.entryTtl(Duration.ofHours(1));
|
RedisCacheConfiguration oneHourConfig = config.entryTtl(Duration.ofHours(1));
|
||||||
|
RedisCacheConfiguration tenMinutesConfig = config.entryTtl(Duration.ofMinutes(10));
|
||||||
cacheConfigs.put(TAG_CACHE_NAME, oneHourConfig);
|
cacheConfigs.put(TAG_CACHE_NAME, oneHourConfig);
|
||||||
cacheConfigs.put(CATEGORY_CACHE_NAME, oneHourConfig);
|
cacheConfigs.put(CATEGORY_CACHE_NAME, oneHourConfig);
|
||||||
|
cacheConfigs.put(POST_CACHE_NAME, tenMinutesConfig);
|
||||||
|
|
||||||
return RedisCacheManager.builder(connectionFactory)
|
return RedisCacheManager.builder(connectionFactory)
|
||||||
.cacheDefaults(config)
|
.cacheDefaults(config)
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
package com.openisle.repository;
|
package com.openisle.repository;
|
||||||
|
|
||||||
import com.openisle.model.PointHistory;
|
|
||||||
import com.openisle.model.User;
|
|
||||||
import com.openisle.model.Comment;
|
import com.openisle.model.Comment;
|
||||||
|
import com.openisle.model.PointHistory;
|
||||||
|
import com.openisle.model.Post;
|
||||||
|
import com.openisle.model.User;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@@ -14,6 +15,8 @@ public interface PointHistoryRepository extends JpaRepository<PointHistory, Long
|
|||||||
long countByUser(User user);
|
long countByUser(User user);
|
||||||
|
|
||||||
List<PointHistory> findByUserAndCreatedAtAfterOrderByCreatedAtDesc(User user, LocalDateTime createdAt);
|
List<PointHistory> findByUserAndCreatedAtAfterOrderByCreatedAtDesc(User user, LocalDateTime createdAt);
|
||||||
|
|
||||||
List<PointHistory> findByComment(Comment comment);
|
List<PointHistory> findByComment(Comment comment);
|
||||||
|
|
||||||
|
List<PointHistory> findByPost(Post post);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,4 +8,6 @@ import java.util.List;
|
|||||||
|
|
||||||
public interface PostChangeLogRepository extends JpaRepository<PostChangeLog, Long> {
|
public interface PostChangeLogRepository extends JpaRepository<PostChangeLog, Long> {
|
||||||
List<PostChangeLog> findByPostOrderByCreatedAtAsc(Post post);
|
List<PostChangeLog> findByPostOrderByCreatedAtAsc(Post post);
|
||||||
|
|
||||||
|
void deleteByPost(Post post);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,6 +109,10 @@ public class PostChangeLogService {
|
|||||||
logRepository.save(log);
|
logRepository.save(log);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void deleteLogsForPost(Post post) {
|
||||||
|
logRepository.deleteByPost(post);
|
||||||
|
}
|
||||||
|
|
||||||
public List<PostChangeLog> listLogs(Long postId) {
|
public List<PostChangeLog> listLogs(Long postId) {
|
||||||
Post post = postRepository.findById(postId)
|
Post post = postRepository.findById(postId)
|
||||||
.orElseThrow(() -> new com.openisle.exception.NotFoundException("Post not found"));
|
.orElseThrow(() -> new com.openisle.exception.NotFoundException("Post not found"));
|
||||||
|
|||||||
@@ -9,14 +9,12 @@ import com.openisle.repository.PollPostRepository;
|
|||||||
import com.openisle.repository.UserRepository;
|
import com.openisle.repository.UserRepository;
|
||||||
import com.openisle.repository.CategoryRepository;
|
import com.openisle.repository.CategoryRepository;
|
||||||
import com.openisle.repository.TagRepository;
|
import com.openisle.repository.TagRepository;
|
||||||
import com.openisle.service.SubscriptionService;
|
|
||||||
import com.openisle.service.CommentService;
|
|
||||||
import com.openisle.service.PostChangeLogService;
|
|
||||||
import com.openisle.repository.CommentRepository;
|
import com.openisle.repository.CommentRepository;
|
||||||
import com.openisle.repository.ReactionRepository;
|
import com.openisle.repository.ReactionRepository;
|
||||||
import com.openisle.repository.PostSubscriptionRepository;
|
import com.openisle.repository.PostSubscriptionRepository;
|
||||||
import com.openisle.repository.NotificationRepository;
|
import com.openisle.repository.NotificationRepository;
|
||||||
import com.openisle.repository.PollVoteRepository;
|
import com.openisle.repository.PollVoteRepository;
|
||||||
|
import com.openisle.repository.PointHistoryRepository;
|
||||||
import com.openisle.exception.RateLimitException;
|
import com.openisle.exception.RateLimitException;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@@ -74,6 +72,7 @@ public class PostService {
|
|||||||
private final ApplicationContext applicationContext;
|
private final ApplicationContext applicationContext;
|
||||||
private final PointService pointService;
|
private final PointService pointService;
|
||||||
private final PostChangeLogService postChangeLogService;
|
private final PostChangeLogService postChangeLogService;
|
||||||
|
private final PointHistoryRepository pointHistoryRepository;
|
||||||
private final ConcurrentMap<Long, ScheduledFuture<?>> scheduledFinalizations = new ConcurrentHashMap<>();
|
private final ConcurrentMap<Long, ScheduledFuture<?>> scheduledFinalizations = new ConcurrentHashMap<>();
|
||||||
@Value("${app.website-url:https://www.open-isle.com}")
|
@Value("${app.website-url:https://www.open-isle.com}")
|
||||||
private String websiteUrl;
|
private String websiteUrl;
|
||||||
@@ -102,6 +101,7 @@ public class PostService {
|
|||||||
ApplicationContext applicationContext,
|
ApplicationContext applicationContext,
|
||||||
PointService pointService,
|
PointService pointService,
|
||||||
PostChangeLogService postChangeLogService,
|
PostChangeLogService postChangeLogService,
|
||||||
|
PointHistoryRepository pointHistoryRepository,
|
||||||
@Value("${app.post.publish-mode:DIRECT}") PublishMode publishMode,
|
@Value("${app.post.publish-mode:DIRECT}") PublishMode publishMode,
|
||||||
RedisTemplate redisTemplate) {
|
RedisTemplate redisTemplate) {
|
||||||
this.postRepository = postRepository;
|
this.postRepository = postRepository;
|
||||||
@@ -125,6 +125,7 @@ public class PostService {
|
|||||||
this.applicationContext = applicationContext;
|
this.applicationContext = applicationContext;
|
||||||
this.pointService = pointService;
|
this.pointService = pointService;
|
||||||
this.postChangeLogService = postChangeLogService;
|
this.postChangeLogService = postChangeLogService;
|
||||||
|
this.pointHistoryRepository = pointHistoryRepository;
|
||||||
this.publishMode = publishMode;
|
this.publishMode = publishMode;
|
||||||
|
|
||||||
this.redisTemplate = redisTemplate;
|
this.redisTemplate = redisTemplate;
|
||||||
@@ -190,7 +191,7 @@ public class PostService {
|
|||||||
return saved;
|
return saved;
|
||||||
}
|
}
|
||||||
@CacheEvict(
|
@CacheEvict(
|
||||||
value = CachingConfig.POST_CACHE_NAME, allEntries = true
|
value = CachingConfig.POST_CACHE_NAME, allEntries = true
|
||||||
)
|
)
|
||||||
public Post createPost(String username,
|
public Post createPost(String username,
|
||||||
Long categoryId,
|
Long categoryId,
|
||||||
@@ -861,6 +862,25 @@ public class PostService {
|
|||||||
notificationRepository.deleteAll(notificationRepository.findByPost(post));
|
notificationRepository.deleteAll(notificationRepository.findByPost(post));
|
||||||
postReadService.deleteByPost(post);
|
postReadService.deleteByPost(post);
|
||||||
imageUploader.removeReferences(imageUploader.extractUrls(post.getContent()));
|
imageUploader.removeReferences(imageUploader.extractUrls(post.getContent()));
|
||||||
|
List<PointHistory> pointHistories = pointHistoryRepository.findByPost(post);
|
||||||
|
Set<User> usersToRecalculate = pointHistories.stream()
|
||||||
|
.map(PointHistory::getUser)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
if (!pointHistories.isEmpty()) {
|
||||||
|
LocalDateTime deletedAt = LocalDateTime.now();
|
||||||
|
for (PointHistory history : pointHistories) {
|
||||||
|
history.setDeletedAt(deletedAt);
|
||||||
|
history.setPost(null);
|
||||||
|
}
|
||||||
|
pointHistoryRepository.saveAll(pointHistories);
|
||||||
|
}
|
||||||
|
if (!usersToRecalculate.isEmpty()) {
|
||||||
|
for (User affected : usersToRecalculate) {
|
||||||
|
int newPoints = pointService.recalculateUserPoints(affected);
|
||||||
|
affected.setPoint(newPoints);
|
||||||
|
}
|
||||||
|
userRepository.saveAll(usersToRecalculate);
|
||||||
|
}
|
||||||
if (post instanceof LotteryPost lp) {
|
if (post instanceof LotteryPost lp) {
|
||||||
ScheduledFuture<?> future = scheduledFinalizations.remove(lp.getId());
|
ScheduledFuture<?> future = scheduledFinalizations.remove(lp.getId());
|
||||||
if (future != null) {
|
if (future != null) {
|
||||||
@@ -868,6 +888,7 @@ public class PostService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
String title = post.getTitle();
|
String title = post.getTitle();
|
||||||
|
postChangeLogService.deleteLogsForPost(post);
|
||||||
postRepository.delete(post);
|
postRepository.delete(post);
|
||||||
if (adminDeleting) {
|
if (adminDeleting) {
|
||||||
notificationService.createNotification(author, NotificationType.POST_DELETED,
|
notificationService.createNotification(author, NotificationType.POST_DELETED,
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ public class UserService {
|
|||||||
* @param user
|
* @param user
|
||||||
*/
|
*/
|
||||||
public void sendVerifyMail(User user, VerifyType verifyType){
|
public void sendVerifyMail(User user, VerifyType verifyType){
|
||||||
//缓存验证码
|
// 缓存验证码
|
||||||
String code = genCode();
|
String code = genCode();
|
||||||
String key;
|
String key;
|
||||||
String subject;
|
String subject;
|
||||||
|
|||||||
@@ -10,8 +10,11 @@ import org.springframework.data.redis.core.RedisTemplate;
|
|||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import org.mockito.ArgumentCaptor;
|
||||||
|
|
||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
@@ -39,12 +42,14 @@ class PostServiceTest {
|
|||||||
ApplicationContext context = mock(ApplicationContext.class);
|
ApplicationContext context = mock(ApplicationContext.class);
|
||||||
PointService pointService = mock(PointService.class);
|
PointService pointService = mock(PointService.class);
|
||||||
PostChangeLogService postChangeLogService = mock(PostChangeLogService.class);
|
PostChangeLogService postChangeLogService = mock(PostChangeLogService.class);
|
||||||
|
PointHistoryRepository pointHistoryRepository = mock(PointHistoryRepository.class);
|
||||||
RedisTemplate redisTemplate = mock(RedisTemplate.class);
|
RedisTemplate redisTemplate = mock(RedisTemplate.class);
|
||||||
|
|
||||||
PostService service = new PostService(postRepo, userRepo, catRepo, tagRepo, lotteryRepo,
|
PostService service = new PostService(postRepo, userRepo, catRepo, tagRepo, lotteryRepo,
|
||||||
pollPostRepo, pollVoteRepo, notifService, subService, commentService, commentRepo,
|
pollPostRepo, pollVoteRepo, notifService, subService, commentService, commentRepo,
|
||||||
reactionRepo, subRepo, notificationRepo, postReadService,
|
reactionRepo, subRepo, notificationRepo, postReadService,
|
||||||
imageUploader, taskScheduler, emailSender, context, pointService, postChangeLogService, PublishMode.DIRECT, redisTemplate);
|
imageUploader, taskScheduler, emailSender, context, pointService, postChangeLogService,
|
||||||
|
pointHistoryRepository, PublishMode.DIRECT, redisTemplate);
|
||||||
when(context.getBean(PostService.class)).thenReturn(service);
|
when(context.getBean(PostService.class)).thenReturn(service);
|
||||||
|
|
||||||
Post post = new Post();
|
Post post = new Post();
|
||||||
@@ -60,11 +65,13 @@ class PostServiceTest {
|
|||||||
when(reactionRepo.findByPost(post)).thenReturn(List.of());
|
when(reactionRepo.findByPost(post)).thenReturn(List.of());
|
||||||
when(subRepo.findByPost(post)).thenReturn(List.of());
|
when(subRepo.findByPost(post)).thenReturn(List.of());
|
||||||
when(notificationRepo.findByPost(post)).thenReturn(List.of());
|
when(notificationRepo.findByPost(post)).thenReturn(List.of());
|
||||||
|
when(pointHistoryRepository.findByPost(post)).thenReturn(List.of());
|
||||||
|
|
||||||
service.deletePost(1L, "alice");
|
service.deletePost(1L, "alice");
|
||||||
|
|
||||||
verify(postReadService).deleteByPost(post);
|
verify(postReadService).deleteByPost(post);
|
||||||
verify(postRepo).delete(post);
|
verify(postRepo).delete(post);
|
||||||
|
verify(postChangeLogService).deleteLogsForPost(post);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -90,12 +97,14 @@ class PostServiceTest {
|
|||||||
ApplicationContext context = mock(ApplicationContext.class);
|
ApplicationContext context = mock(ApplicationContext.class);
|
||||||
PointService pointService = mock(PointService.class);
|
PointService pointService = mock(PointService.class);
|
||||||
PostChangeLogService postChangeLogService = mock(PostChangeLogService.class);
|
PostChangeLogService postChangeLogService = mock(PostChangeLogService.class);
|
||||||
|
PointHistoryRepository pointHistoryRepository = mock(PointHistoryRepository.class);
|
||||||
RedisTemplate redisTemplate = mock(RedisTemplate.class);
|
RedisTemplate redisTemplate = mock(RedisTemplate.class);
|
||||||
|
|
||||||
PostService service = new PostService(postRepo, userRepo, catRepo, tagRepo, lotteryRepo,
|
PostService service = new PostService(postRepo, userRepo, catRepo, tagRepo, lotteryRepo,
|
||||||
pollPostRepo, pollVoteRepo, notifService, subService, commentService, commentRepo,
|
pollPostRepo, pollVoteRepo, notifService, subService, commentService, commentRepo,
|
||||||
reactionRepo, subRepo, notificationRepo, postReadService,
|
reactionRepo, subRepo, notificationRepo, postReadService,
|
||||||
imageUploader, taskScheduler, emailSender, context, pointService, postChangeLogService, PublishMode.DIRECT, redisTemplate);
|
imageUploader, taskScheduler, emailSender, context, pointService, postChangeLogService,
|
||||||
|
pointHistoryRepository, PublishMode.DIRECT, redisTemplate);
|
||||||
when(context.getBean(PostService.class)).thenReturn(service);
|
when(context.getBean(PostService.class)).thenReturn(service);
|
||||||
|
|
||||||
Post post = new Post();
|
Post post = new Post();
|
||||||
@@ -117,6 +126,7 @@ class PostServiceTest {
|
|||||||
when(reactionRepo.findByPost(post)).thenReturn(List.of());
|
when(reactionRepo.findByPost(post)).thenReturn(List.of());
|
||||||
when(subRepo.findByPost(post)).thenReturn(List.of());
|
when(subRepo.findByPost(post)).thenReturn(List.of());
|
||||||
when(notificationRepo.findByPost(post)).thenReturn(List.of());
|
when(notificationRepo.findByPost(post)).thenReturn(List.of());
|
||||||
|
when(pointHistoryRepository.findByPost(post)).thenReturn(List.of());
|
||||||
|
|
||||||
service.deletePost(1L, "admin");
|
service.deletePost(1L, "admin");
|
||||||
|
|
||||||
@@ -147,12 +157,14 @@ class PostServiceTest {
|
|||||||
ApplicationContext context = mock(ApplicationContext.class);
|
ApplicationContext context = mock(ApplicationContext.class);
|
||||||
PointService pointService = mock(PointService.class);
|
PointService pointService = mock(PointService.class);
|
||||||
PostChangeLogService postChangeLogService = mock(PostChangeLogService.class);
|
PostChangeLogService postChangeLogService = mock(PostChangeLogService.class);
|
||||||
|
PointHistoryRepository pointHistoryRepository = mock(PointHistoryRepository.class);
|
||||||
RedisTemplate redisTemplate = mock(RedisTemplate.class);
|
RedisTemplate redisTemplate = mock(RedisTemplate.class);
|
||||||
|
|
||||||
PostService service = new PostService(postRepo, userRepo, catRepo, tagRepo, lotteryRepo,
|
PostService service = new PostService(postRepo, userRepo, catRepo, tagRepo, lotteryRepo,
|
||||||
pollPostRepo, pollVoteRepo, notifService, subService, commentService, commentRepo,
|
pollPostRepo, pollVoteRepo, notifService, subService, commentService, commentRepo,
|
||||||
reactionRepo, subRepo, notificationRepo, postReadService,
|
reactionRepo, subRepo, notificationRepo, postReadService,
|
||||||
imageUploader, taskScheduler, emailSender, context, pointService, postChangeLogService, PublishMode.DIRECT, redisTemplate);
|
imageUploader, taskScheduler, emailSender, context, pointService, postChangeLogService,
|
||||||
|
pointHistoryRepository, PublishMode.DIRECT, redisTemplate);
|
||||||
when(context.getBean(PostService.class)).thenReturn(service);
|
when(context.getBean(PostService.class)).thenReturn(service);
|
||||||
|
|
||||||
when(postRepo.countByAuthorAfter(eq("alice"), any())).thenReturn(1L);
|
when(postRepo.countByAuthorAfter(eq("alice"), any())).thenReturn(1L);
|
||||||
@@ -162,6 +174,77 @@ class PostServiceTest {
|
|||||||
null, null, null, null, null, null, null, null, null));
|
null, null, null, null, null, null, null, null, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void deletePostRemovesPointHistoriesAndRecalculatesPoints() {
|
||||||
|
PostRepository postRepo = mock(PostRepository.class);
|
||||||
|
UserRepository userRepo = mock(UserRepository.class);
|
||||||
|
CategoryRepository catRepo = mock(CategoryRepository.class);
|
||||||
|
TagRepository tagRepo = mock(TagRepository.class);
|
||||||
|
LotteryPostRepository lotteryRepo = mock(LotteryPostRepository.class);
|
||||||
|
PollPostRepository pollPostRepo = mock(PollPostRepository.class);
|
||||||
|
PollVoteRepository pollVoteRepo = mock(PollVoteRepository.class);
|
||||||
|
NotificationService notifService = mock(NotificationService.class);
|
||||||
|
SubscriptionService subService = mock(SubscriptionService.class);
|
||||||
|
CommentService commentService = mock(CommentService.class);
|
||||||
|
CommentRepository commentRepo = mock(CommentRepository.class);
|
||||||
|
ReactionRepository reactionRepo = mock(ReactionRepository.class);
|
||||||
|
PostSubscriptionRepository subRepo = mock(PostSubscriptionRepository.class);
|
||||||
|
NotificationRepository notificationRepo = mock(NotificationRepository.class);
|
||||||
|
PostReadService postReadService = mock(PostReadService.class);
|
||||||
|
ImageUploader imageUploader = mock(ImageUploader.class);
|
||||||
|
TaskScheduler taskScheduler = mock(TaskScheduler.class);
|
||||||
|
EmailSender emailSender = mock(EmailSender.class);
|
||||||
|
ApplicationContext context = mock(ApplicationContext.class);
|
||||||
|
PointService pointService = mock(PointService.class);
|
||||||
|
PostChangeLogService postChangeLogService = mock(PostChangeLogService.class);
|
||||||
|
PointHistoryRepository pointHistoryRepository = mock(PointHistoryRepository.class);
|
||||||
|
RedisTemplate redisTemplate = mock(RedisTemplate.class);
|
||||||
|
|
||||||
|
PostService service = new PostService(postRepo, userRepo, catRepo, tagRepo, lotteryRepo,
|
||||||
|
pollPostRepo, pollVoteRepo, notifService, subService, commentService, commentRepo,
|
||||||
|
reactionRepo, subRepo, notificationRepo, postReadService,
|
||||||
|
imageUploader, taskScheduler, emailSender, context, pointService, postChangeLogService,
|
||||||
|
pointHistoryRepository, PublishMode.DIRECT, redisTemplate);
|
||||||
|
when(context.getBean(PostService.class)).thenReturn(service);
|
||||||
|
|
||||||
|
Post post = new Post();
|
||||||
|
post.setId(10L);
|
||||||
|
User author = new User();
|
||||||
|
author.setId(20L);
|
||||||
|
author.setRole(Role.USER);
|
||||||
|
post.setAuthor(author);
|
||||||
|
|
||||||
|
User historyUser = new User();
|
||||||
|
historyUser.setId(30L);
|
||||||
|
|
||||||
|
PointHistory history = new PointHistory();
|
||||||
|
history.setUser(historyUser);
|
||||||
|
history.setPost(post);
|
||||||
|
|
||||||
|
when(postRepo.findById(10L)).thenReturn(Optional.of(post));
|
||||||
|
when(userRepo.findByUsername("author")).thenReturn(Optional.of(author));
|
||||||
|
when(commentRepo.findByPostAndParentIsNullOrderByCreatedAtAsc(post)).thenReturn(List.of());
|
||||||
|
when(reactionRepo.findByPost(post)).thenReturn(List.of());
|
||||||
|
when(subRepo.findByPost(post)).thenReturn(List.of());
|
||||||
|
when(notificationRepo.findByPost(post)).thenReturn(List.of());
|
||||||
|
when(pointHistoryRepository.findByPost(post)).thenReturn(List.of(history));
|
||||||
|
when(pointService.recalculateUserPoints(historyUser)).thenReturn(0);
|
||||||
|
|
||||||
|
service.deletePost(10L, "author");
|
||||||
|
|
||||||
|
ArgumentCaptor<List<PointHistory>> captor = ArgumentCaptor.forClass(List.class);
|
||||||
|
verify(pointHistoryRepository).saveAll(captor.capture());
|
||||||
|
List<PointHistory> savedHistories = captor.getValue();
|
||||||
|
assertEquals(1, savedHistories.size());
|
||||||
|
PointHistory savedHistory = savedHistories.get(0);
|
||||||
|
assertNull(savedHistory.getPost());
|
||||||
|
assertNotNull(savedHistory.getDeletedAt());
|
||||||
|
assertTrue(savedHistory.getDeletedAt().isBefore(LocalDateTime.now().plusSeconds(1)));
|
||||||
|
|
||||||
|
verify(pointService).recalculateUserPoints(historyUser);
|
||||||
|
verify(userRepo).saveAll(any());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void finalizeLotteryNotifiesAuthor() {
|
void finalizeLotteryNotifiesAuthor() {
|
||||||
PostRepository postRepo = mock(PostRepository.class);
|
PostRepository postRepo = mock(PostRepository.class);
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
--primary-color-hover: rgb(9, 95, 105);
|
--primary-color-hover: rgb(9, 95, 105);
|
||||||
--primary-color: rgb(10, 110, 120);
|
--primary-color: rgb(10, 110, 120);
|
||||||
--primary-color-disabled: rgba(93, 152, 156, 0.5);
|
--primary-color-disabled: rgba(93, 152, 156, 0.5);
|
||||||
--secondary-color:rgb(255, 255, 255);
|
--secondary-color: rgb(255, 255, 255);
|
||||||
--secondary-color-hover:rgba(165, 255, 255, 0.447);
|
--secondary-color-hover: rgba(10, 111, 120, 0.184);
|
||||||
--new-post-icon-color: rgba(10, 111, 120, 0.598);
|
--new-post-icon-color: rgba(10, 111, 120, 0.598);
|
||||||
--header-height: 60px;
|
--header-height: 60px;
|
||||||
--header-background-color: white;
|
--header-background-color: white;
|
||||||
|
|||||||
@@ -712,13 +712,13 @@ watch(selectedTab, async (val) => {
|
|||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
padding: 5px 10px;
|
padding: 5px 10px;
|
||||||
color: var(--primary-color);
|
color: var(--primary-color);
|
||||||
background-color: var(--secondary-color);
|
|
||||||
border: 1px solid var(--primary-color);
|
border: 1px solid var(--primary-color);
|
||||||
margin-top: 15px;
|
margin-top: 15px;
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.profile-page-header-unsubscribe-button:hover,
|
||||||
.profile-page-header-send-mail-button:hover {
|
.profile-page-header-send-mail-button:hover {
|
||||||
background-color: var(--secondary-color-hover);
|
background-color: var(--secondary-color-hover);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user