Fix index for merged train cars
What does this MR do and why?
Resolves #465252 (closed)
This MR modifies MergeTrains::Car#index
to return nil
if the car is in an active state (not merging or merged).
Right now, Car#index
successfully ticks down for active cars on the train, but all merged cars show an index of 0
because they can't go any lower. The car asks the train, of all active cars on the same Train, how many have a lower id? But it doesn't specifically check the status of the car asking in the first place. So once it reaches 0
, it will just stay 0
forever.
I added a pretty simple check to the top of the index
method. The scope that MergeTrains::Train#all_cars
uses is active
, built by the same logic that builds the active
method we use here.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.