Skip to content

Commit c807bfc

Browse files
sukangpunchclaude
andauthored
feat: 게시글 카테고리에 동행, 중고거래 추가
* feat: 게시글 카테고리에 동행, 중고거래 추가 - PostCategory enum에 동행, 중고거래 추가 - post 테이블 category ENUM 컬럼 마이그레이션 (V52) - 신규 카테고리 게시글 생성 및 카테고리별 조회 필터링 테스트 추가 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * test: 성공적 생성 테스트와 중복되는 카테고리 생성 테스트 제거 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix: flyway 버전 충돌 해결 --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 443665f commit c807bfc

3 files changed

Lines changed: 53 additions & 1 deletion

File tree

src/main/java/com/example/solidconnection/community/post/domain/PostCategory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import java.util.stream.Collectors;
66

77
public enum PostCategory {
8-
전체, 자유, 질문;
8+
전체, 자유, 질문, 동행, 중고거래;
99

1010
private static final Set<String> NAMES = Arrays.stream(values())
1111
.map(Enum::name)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE post
2+
MODIFY COLUMN category ENUM ('자유', '전체', '질문', '동행', '중고거래') NULL;

src/test/java/com/example/solidconnection/community/post/service/PostQueryServiceTest.java

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,56 @@ void setUp() {
135135
);
136136
}
137137

138+
@Test
139+
void 동행_카테고리로_조회시_해당_카테고리의_게시글만_조회한다() {
140+
// given
141+
Post 동행_게시글 = postFixture.게시글(
142+
"동행 제목",
143+
"동행 내용",
144+
false,
145+
PostCategory.동행,
146+
boardFixture.자유게시판(),
147+
user
148+
);
149+
150+
// when
151+
List<PostListResponse> actualResponses = postQueryService.findPostsByCodeAndPostCategoryOrderByCreatedAtDesc(
152+
BoardCode.FREE.name(),
153+
PostCategory.동행.name(),
154+
null
155+
);
156+
157+
// then
158+
assertThat(actualResponses)
159+
.extracting(PostListResponse::id)
160+
.containsExactly(동행_게시글.getId());
161+
}
162+
163+
@Test
164+
void 중고거래_카테고리로_조회시_해당_카테고리의_게시글만_조회한다() {
165+
// given
166+
Post 중고거래_게시글 = postFixture.게시글(
167+
"중고거래 제목",
168+
"중고거래 내용",
169+
false,
170+
PostCategory.중고거래,
171+
boardFixture.자유게시판(),
172+
user
173+
);
174+
175+
// when
176+
List<PostListResponse> actualResponses = postQueryService.findPostsByCodeAndPostCategoryOrderByCreatedAtDesc(
177+
BoardCode.FREE.name(),
178+
PostCategory.중고거래.name(),
179+
null
180+
);
181+
182+
// then
183+
assertThat(actualResponses)
184+
.extracting(PostListResponse::id)
185+
.containsExactly(중고거래_게시글.getId());
186+
}
187+
138188
@Test
139189
void 전체_카테고리로_조회시_해당_게시판의_모든_게시글을_조회한다() {
140190
// given

0 commit comments

Comments
 (0)