Fix iterations_in_advance mismatch between backend and frontend
The number of iterations that can be created in advance tops at 10 in the backend:
# ee/app/models/iterations/cadence.rb
validates :iterations_in_advance, inclusion: { in: 0..10 }, allow_nil: true
However, in the frontend, a user is able to choose 12 as an option:
// ee/app/assets/javascripts/iterations/components/iteration_cadence_form.vue
availableFutureIterations: [
{ value: 0, text: i18n.futureIterations.placeholder },
2,
4,
6,
8,
10,
12,
],
The discrepancy causes an error when creating a cadence with iterationsInAdvance=12
(#348763).
Screen_Recording_2021-12-17_at_10.22.42_AM
Fix
Although the backend fix is trivial (changing 0..10
to 0..12
in cadence.rb#20 should do) , we should consider additional changes to ensure the frontend and backend always use a SSOT.
-
Validate the values for the argument
IterationsInAdvance
through the GraphQL after declaring the possible range in the Cadence model. -
Possibly use the GraphQL introspection or pass the range (1 to 12) through HAML to the frontend.
Edited by euko