Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,10 @@ public Slice<PostWithVoteCount> findVotedPostsWithVoteCount(Long userId, Long po
JPAExpressions
.select(vote.postId)
.from(vote)
.where(vote.userId.eq(userId))
.where(
vote.userId.eq(userId),
vote.deleted.isFalse()
)
),
cursor(postId, post.id),
post.deleted.isFalse()
Expand Down
11 changes: 11 additions & 0 deletions src/test/java/com/chooz/post/application/PostQueryServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.chooz.thumbnail.domain.ThumbnailRepository;
import com.chooz.user.domain.User;
import com.chooz.user.domain.UserRepository;
import com.chooz.vote.application.VoteService;
import com.chooz.vote.domain.Vote;
import com.chooz.vote.domain.VoteRepository;
import org.junit.jupiter.api.DisplayName;
Expand Down Expand Up @@ -53,6 +54,8 @@ class PostQueryServiceTest extends IntegrationTest {

@Autowired
ThumbnailRepository thumbnailRepository;
@Autowired
private VoteService voteService;

@Test
@DisplayName("게시글 조회")
Expand Down Expand Up @@ -242,10 +245,18 @@ void findVotedPosts_multiple() {
.userId(user.getId())
.pollOption(PostFixture.multiplePollOption())
.build());
Post post2 = postRepository.save(PostFixture.createPostBuilder()
.userId(user.getId())
.pollOption(PostFixture.multiplePollOption())
.build());
//유저1 선택지 1, 2 복수 투표
voteRepository.save(VoteFixture.createDefaultVote(user.getId(), post.getId(), post.getPollChoices().get(0).getId()));
voteRepository.save(VoteFixture.createDefaultVote(user.getId(), post.getId(), post.getPollChoices().get(1).getId()));

//유저1 게시글2 투표 후 취소
voteRepository.save(VoteFixture.createDefaultVote(user.getId(), post2.getId(), post2.getPollChoices().get(1).getId()));
voteService.vote(user.getId(), post2.getId(), List.of());

//when
var response = postService.findVotedPosts(user.getId(), null, 10);

Expand Down