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

Abierto
#2,939 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
78/100
Tipo de issue
Refactorización
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
rails, ruby
Área
backend

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.
Lenguaje dominante
Ruby
Estrellas
106
Forks
208
Merge medio
19 h 51 min
PR fusionados (30 d)
57

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de codebar/planner

Todos los issues de codebar/planner

Issues similares

Más issues de Ruby

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.