Admin QT 콘텐츠 CRUD + 테스트

ID: 15d4b692-096c-4043-86d2-d7f3659764d4

높음 완료

## 목표
Admin namespace에 QT 콘텐츠 CRUD 구현 (테마 하위 nested resource)

## 선행 조건
- admin-themes 에이전트가 라우트와 테마 CRUD를 완성한 후 시작

## 구현 항목

### 1. Admin::QtContentsController (신규)
- 파일: `app/controllers/admin/qt_contents_controller.rb`
- Admin::BaseController 상속
- before_action :set_theme (모든 액션)
- before_action :set_content (show, edit, update, destroy)
- 액션: index, show, new, create, edit, update, destroy
- index: @theme.qt_contents.order(:day_number)
- show: 콘텐츠 상세
- new: @theme.qt_contents.build(day_number: next_day)
- create/update: 기본 CRUD
- destroy: 삭제 후 테마 show로 redirect
- strong params: day_number, week_number, bible_passage, reading_passage, theme_title, content, questions, difficulty, estimated_minutes, tags, bible_chapter, bible_verse
- questions 파라미터 처리: JSON 문자열 → 배열 변환

### 2. 뷰 (신규)
- `app/views/admin/qt_contents/index.html.erb`:
- 제목 "[테마명] 콘텐츠 관리" + "콘텐츠 추가" 버튼 + "테마로 돌아가기" 링크
- shared/_table.html.erb로 목록 (헤더: 일차, 주차, 성경구절, 제목, 난이도, 액션)
- 난이도는 숫자 (1-5)

- `app/views/admin/qt_contents/show.html.erb`:
- 콘텐츠 상세 (성경구절, 제목, 본문, 질문, 난이도, 소요시간)
- 질문은 번호 매기기 (ol 태그)
- 수정/삭제 버튼

- `app/views/admin/qt_contents/new.html.erb` + `edit.html.erb`:
- _form.html.erb 파셜 렌더링

- `app/views/admin/qt_contents/_form.html.erb`:
- shared/_input 사용: day_number(number, required), week_number(number), bible_passage(required), reading_passage, theme_title(required), content(textarea, required), estimated_minutes(number), tags, bible_chapter(number), bible_verse(number)
- shared/_select 사용: difficulty (1-5 선택지)
- questions: textarea (JSON 배열 형태, 한 줄에 질문 하나, JS 없이 각 줄을 배열로 변환)
- 예시 placeholder: "하나님의 창조 순서에서 무엇을 느꼈나요?\n오늘의 말씀이 나에게 주는 의미는?"
- 컨트롤러에서 줄바꿈으로 split하여 배열로 저장
- 제출/취소 버튼

### 3. 테스트 (신규)
- `test/controllers/admin/qt_contents_controller_test.rb`
- 테스트 케이스:
- admin 로그인 후 콘텐츠 목록 조회 (GET /admin/qt_themes/:theme_id/qt_contents)
- admin 로그인 후 콘텐츠 생성 (POST /admin/qt_themes/:theme_id/qt_contents)
- admin 로그인 후 콘텐츠 수정 (PATCH /admin/qt_themes/:theme_id/qt_contents/:id)
- admin 로그인 후 콘텐츠 삭제 (DELETE /admin/qt_themes/:theme_id/qt_contents/:id)
- 일반 사용자 접근 차단
- Fixture: qt_themes(:default_theme), qt_contents(:day_one), users(:admin)
- nested URL 패턴: admin_qt_theme_qt_contents_path(qt_themes(:default_theme))

## 주의사항
- UUID PK (ApplicationRecord의 set_uuid)
- ERB 멀티라인 주석 금지
- shared 파셜 strict locals 정확히 준수
- Tailwind CSS v4 의미 기반 색상 사용
- questions JSON 배열 처리: 줄바꿈 split → 배열 변환, 표시 시 배열 → 줄바꿈 join
- SQLite JSON 컬럼 주의: JSON.parse 필요할 수 있음
- 전체 테스트 통과 확인: bin/rails test

첨부 이미지

이미지 추가 (Ctrl+V로 붙여넣기 또는 클릭)

JPEG, PNG, GIF, WebP / 최대 10MB

담당자: admin-contents
생성일: 2026년 03월 02일 05:02

활동 로그

  • 팀리드 상태 변경: 리뷰 → 완료

    2026년 03월 02일 05:12:37

  • A
    admin-contents 상태 변경: 진행 중 → 리뷰

    2026년 03월 02일 05:12:14

  • A
    admin-contents Admin QT 콘텐츠 CRUD 구현 완료 - 전체 테스트 401 runs 통과

    2026년 03월 02일 05:12:13

    상세 보기

    ## 생성된 파일
    - `app/controllers/admin/qt_contents_controller.rb` - 콘텐츠 CRUD 컨트롤러 (index/show/new/create/edit/update/destroy)
    - `app/views/admin/qt_contents/index.html.erb` - 콘텐츠 목록 (shared/_table 활용)
    - `app/views/admin/qt_contents/show.html.erb` - 콘텐츠 상세 (shared/_card 활용, 질문 ol 목록)
    - `app/views/admin/qt_contents/new.html.erb` - 생성 폼
    - `app/views/admin/qt_contents/edit.html.erb` - 수정 폼
    - `app/views/admin/qt_contents/_form.html.erb` - 폼 파셜 (shared/_input, _select 활용)
    - `test/controllers/admin/qt_contents_controller_test.rb` - 11개 테스트 케이스

    ## 주요 구현 사항
    - Admin::BaseController 상속, before_action으로 테마/콘텐츠 설정
    - questions 필드: 줄바꿈 텍스트 → 배열 변환 (컨트롤러), 배열 → 줄바꿈 join (뷰)
    - SQLite JSON 컬럼 대응: JSON.parse 사용
    - shared 파셜 strict locals 준수
    - Tailwind CSS v4 의미 기반 색상 사용

    ## 테스트 결과
    - 콘텐츠 컨트롤러: 11 runs, 28 assertions, 0 failures
    - 전체: 401 runs, 928 assertions, 0 failures, 0 errors

  • A
    admin-contents 작업 시작 - 기존 코드 파악 중

    2026년 03월 02일 05:09:47

  • A
    admin-contents 티켓 클레임 완료

    2026년 03월 02일 05:09:43