부모 티켓
1개 티켓

백로그

0
티켓 없음

할 일

0
티켓 없음

진행 중

0
티켓 없음

리뷰

1
높음 c87419b3
서브 티켓 [P1] 라우트 설정 (전체)

라우트 설정 — PRD Section 10 전체 라우트 + 스텁 컨트롤러 + 테스트

## 목표 PRD Section 10 전체 라우트를 config/routes.rb에 설정. 필요한 스텁 컨트롤러 생성. 라우트 테스트 작성. ## 현재 routes.rb 상태 ```ruby Rails.application.routes.draw do resource :session resources :passwords, param: :token resources :registrations, only: %i[new create] namespace :onboarding do # ... (4단계 온보딩 — 이미 구현됨) end root "pages#landing" get "up" => "rails/health#show", as: :rails_health_check end ``` ## PRD Section 10 전체 라우트 (목표 상태) ```ruby Rails.application.routes.draw do # 공개 root "pages#landing" get "/about", to: "pages#about" get "/showcase", to: "pages#showcase" get "/pricing", to: "pages#pricing" # 인증 (Rails 8 내장) resource :session resources :passwords, param: :token get "/signup", to: "registrations#new" post "/signup", to: "registrations#create" # 9WAY OAuth get "/auth/nineways", to: "auth/nineways#redirect" get "/auth/nineways/callback", to: "auth/nineways#callback" # 온보딩 (이미 구현됨) namespace :onboarding do get "/", to: "steps#index" get "nineways", to: "steps#nineways" post "nineways", to: "steps#connect_nineways" get "goal", to: "steps#goal" post "goal", to: "steps#save_goal" get "level", to: "steps#level" post "level", to: "steps#save_level" get "idea", to: "steps#idea" post "idea", to: "steps#save_idea" get "complete", to: "steps#complete" end # 인증 필요 구간 — before_action :require_authentication 사용 # PRD의 `authenticated :user do` 블록 대신 컨트롤러에서 인증 체크 get "/dashboard", to: "dashboard#index" # LEARN namespace :learn do get "/" , to: "home#index" resources :curricula, only: [:index, :show] do resources :lessons, only: [:show] do post :complete, on: :member end end end # BUILD namespace :build do get "/", to: "home#index" resources :projects do resource :idea_analysis, only: [:show, :create] resource :spec, only: [:show, :update] resource :blueprint, only: [:show, :create] resource :claude_md, only: [:show, :create] do get :download, on: :member end resources :build_steps, only: [:index, :show] do post :complete, on: :member end end end # LAUNCH namespace :launch do get "/", to: "home#index" resources :projects, only: [] do resource :checklist, only: [:show, :update] resource :copy_generator, only: [:show, :create] end end # AI 코치 resources :ai_conversations, only: [:index, :create, :show] do post :message, on: :member end # 커뮤니티 resources :community_posts do resources :community_comments, only: [:create, :destroy] post :like, on: :member end # 코호트 resources :cohorts, only: [:index, :show] do resources :cohort_applications, only: [:new, :create] resources :cohort_enrollments, only: [:new, :create] end # B2B 문의 resources :b2b_inquiries, only: [:new, :create] # 쇼케이스 resources :showcase_services, only: [:index, :show, :new, :create, :edit, :update] # MY namespace :my do get "/", to: "dashboard#index" resource :profile, only: [:show, :edit, :update] resource :nineways_sync, only: [:create] end # 결제 (토스페이먼츠) namespace :payments do get "/checkout/:plan", to: "checkout#show", as: :checkout post "/checkout/:plan", to: "checkout#create" get "/success", to: "completions#success" get "/fail", to: "completions#fail" end # 토스 웹훅 post "/payments/webhook", to: "payments/webhooks#receive" # 관리자 namespace :admin do root to: "dashboard#index" resources :users resources :cohorts resources :curricula do resources :lessons end resources :cohort_applications resources :b2b_inquiries resources :payments end # 9WAY 웹훅 namespace :api do namespace :v1 do post "/nineways/webhook", to: "nineways#webhook" end end get "up" => "rails/health#show", as: :rails_health_check end ``` ## 스텁 컨트롤러 생성 규칙 - 각 라우트에 대응하는 컨트롤러가 없으면 **빈 스텁 컨트롤러**를 생성 - 이미 존재하는 컨트롤러: PagesController, SessionsController, PasswordsController, RegistrationsController, Onboarding::StepsController - 스텁 컨트롤러 패턴: ```ruby class DashboardController < ApplicationController def index # TODO: 구현 예정 end end ``` - 인증 필요 컨트롤러는 `before_action :require_authentication` 제거하지 않음 (ApplicationController에서 상속) - Admin 네임스페이스 컨트롤러는 `Admin::BaseController`를 만들고 admin 권한 체크: ```ruby class Admin::BaseController < ApplicationController before_action :require_admin private def require_admin redirect_to root_path, alert: I18n.t("errors.messages.not_authorized") unless Current.user&.admin? end end ``` - Admin 하위 컨트롤러는 `Admin::BaseController` 상속 - 각 네임스페이스(learn, build, launch, my, payments, admin)의 컨트롤러 생성 - `allow_unauthenticated_access` 필요한 컨트롤러: PagesController, 웹훅 컨트롤러 ## ⚠️ 주의 - PRD의 `authenticated :user do`는 Devise 패턴 — Rails 8 Authentication은 이를 지원하지 않음 → 대신 ApplicationController의 `before_action :require_authentication`으로 처리 (이미 설정됨) → `allow_unauthenticated_access`로 공개 라우트 해제 - `authenticate :user, ->(u) { u.admin? }` 대신 Admin::BaseController에서 before_action으로 처리 - MissionControl::Jobs::Engine 마운트는 gem이 설치되어 있으면 추가, 없으면 주석 처리 - 기존 `resources :registrations, only: %i[new create]`를 PRD의 `get/post "/signup"` 패턴으로 변경 - 기존 온보딩 라우트 유지 - 토스 웹훅은 `skip_forgery_protection` 필요 - developer-1이 동시에 DB 마이그레이션 작업 중 — routes.rb만 수정, 모델 파일은 건드리지 않기 ## 테스트 - 라우트 테스트: 주요 경로가 올바른 컨트롤러#액션으로 연결되는지 - root → pages#landing - /dashboard → dashboard#index - /learn → learn/home#index - /build → build/home#index - /admin → admin/dashboard#index - 인증 테스트: - 공개 페이지 접근 가능 (root, /about, /pricing, /signup) - 보호 페이지 미인증 시 로그인 리다이렉트 (/dashboard, /learn, /build) - Admin 페이지 비관리자 접근 시 리다이렉트 - `bin/rails routes` 에러 없이 출력 ## 완료 기준 - config/routes.rb PRD Section 10과 일치 - 모든 라우트에 대응하는 컨트롤러 존재 (스텁이라도) - 미인증 사용자 보호 라우트 → 로그인 리다이렉트 - admin 역할만 관리자 라우트 접근 - bin/rails test 전체 통과

D
developer-2
25 days

완료 (30일)

0
티켓 없음