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 @@ -5,7 +5,7 @@
import java.util.stream.Collectors;

public enum PostCategory {
전체, 자유, 질문;
전체, 자유, 질문, 동행, 중고거래;

private static final Set<String> NAMES = Arrays.stream(values())
.map(Enum::name)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE post
MODIFY COLUMN category ENUM ('자유', '전체', '질문', '동행', '중고거래') NULL;
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,56 @@ void setUp() {
);
}

@Test
void 동행_카테고리로_조회시_해당_카테고리의_게시글만_조회한다() {
// given
Post 동행_게시글 = postFixture.게시글(
"동행 제목",
"동행 내용",
false,
PostCategory.동행,
boardFixture.자유게시판(),
user
);

// when
List<PostListResponse> actualResponses = postQueryService.findPostsByCodeAndPostCategoryOrderByCreatedAtDesc(
BoardCode.FREE.name(),
PostCategory.동행.name(),
null
);

// then
assertThat(actualResponses)
.extracting(PostListResponse::id)
.containsExactly(동행_게시글.getId());
}

@Test
void 중고거래_카테고리로_조회시_해당_카테고리의_게시글만_조회한다() {
// given
Post 중고거래_게시글 = postFixture.게시글(
"중고거래 제목",
"중고거래 내용",
false,
PostCategory.중고거래,
boardFixture.자유게시판(),
user
);

// when
List<PostListResponse> actualResponses = postQueryService.findPostsByCodeAndPostCategoryOrderByCreatedAtDesc(
BoardCode.FREE.name(),
PostCategory.중고거래.name(),
null
);

// then
assertThat(actualResponses)
.extracting(PostListResponse::id)
.containsExactly(중고거래_게시글.getId());
}

@Test
void 전체_카테고리로_조회시_해당_게시판의_모든_게시글을_조회한다() {
// given
Expand Down
Loading