Move the "physical workshop needs a host" validation onto Workshop

オープン
#2,939 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
78/100
issue の種類
リファクタリング
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
rails, ruby
領域
backend

調査の方向性

Start with Admin::WorkshopsController, especially workshop_type_valid? and physical_workshop_and_no_host?, then inspect the Workshop model and existing admin workshop controller specs. Move the physical-workshop host rule into Workshop while preserving the host error message, add model specs for the validation, and run the existing controller specs to confirm the flash behaviour remains unchanged.

索引モデルが issue の本文から書いたものです。

説明

refactoring tech debt

Parent: #2938

Problem

Admin::WorkshopsController enforces the rule "a physical workshop must have a host" in the controller (workshop_type_valid? plus physical_workshop_and_no_host?), adding a validation error from the controller:

def workshop_type_valid?
  return true unless physical_workshop_and_no_host?(@workshop)

  @workshop.errors.add(:host, "can't be blank")
  false
end

Validation rules belong on the model so create, update, and any future caller get them for free.

Proposed change

  • Move the rule into a Workshop validation, reusing the controller's intent and error message (host "can't be blank").
  • Delete workshop_type_valid? and physical_workshop_and_no_host? from the controller; the create/update flows keep their existing flash behaviour via @workshop.errors.

Acceptance

  • Creating/updating a physical workshop without a host fails with the same error message as today.
  • Model specs cover the new validation; existing admin workshop controller specs pass.
主要言語
Ruby
スター
106
フォーク
208
平均マージ
19時間 51分
マージ済み PR(30日)
57

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

codebar/planner のほかの issue

codebar/planner の issue をすべて見る

似ている issue

Ruby の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。