Schedule iterations on cadence start weekday
What does this MR do and why?
Completes backend for #354977 (closed)
This MR implements the following requirements outlined in #354977 (closed):
- Iterations should be scheduled on the weekday derived from the cadence start date.
- When the start date of a cadence changes - only possible if it has not already started - the dates of all existing upcoming iterations need to be re-aligned.
Example 1.
- If I create a cadence with a start date of Jun 6
- It is May 1 and I update the cadence to start the cadence on May 1
- The two iterations in June would have their dates changed to May 2-8 and May 9-15 respectively
Example 2. An automatic cadence starts on Thu May 5. The cadence then should schedule iterations to start on Thursdays.
Example 3. The first iteration in a manual cadence started on Wednesday. When it's converted to use automated scheduling, all iterations created after the conversion need to be scheduled on Wednesday.
How to set up and validate locally
The specs have been refactored to closely follow typical user interactions. It may be helpful to reference them.
- Enable Iterations Cadence in the Rails console
Feature.enable(:iteration_cadences)
-
Create a new group (not strictly necessary but recommended to avoid confusion.)
-
Visit Iterations page and create a new cadence. Set the start date to a future date.
-
After iterations are initially scheduled, adjust the cadence's start date again to another future date.
Check that existing iterations are correctly adjusted with the first iteration starting on the new start date of the cadence.
-
Edit the start date of the cadence again. Set the start date to the current date or some date in the past.
Check that existing iterations are correctly adjusted.
Try various scenarios like modifying the duration of a cadence.
demo
Test with a manual cadence
- In the Rails console, enter the following line - just substitute the group - to create a manual cadence (this is faster and less onerous than turning off the feature flag and on again.)
group = Group.find(126)
Iterations::Cadence.new(group: group, start_date: Date.new(2022, 4, 4), last_run_date: nil, duration_in_weeks: 2, iterations_in_advance: 2, active: true, automatic: false, title: "manual cadence", roll_over: false).save!(validate: false)
-
Create some iterations then convert the manual cadence to use automated scheduling.
-
Check that existing past and current iterations stay intact but upcoming iterations are scheduled/adjusted correctly