forms/BallotForm: keep the ranking from the user for ranking questions
Upon parsing the result coming from the user, we convert the DB ids we sent to the user into actual DB-backed python objects. Unfortunately, the _get_objects() helper that performs this conversion did not return the objects in the order the user ranked them, but instead the order in which the objects had been created in the DB... Not only was this oversight was then not caught by unit testing, because test_valid_form() was concentrating on verifying that we were getting the right objects rather than checking the order, but this also escaped our multiple mock election attempts... I guess humans like to rank people based on the number next to them... The fix is simple, albeit inefficient: make one query per option, in the order the user gave us the list. On the unit test side, multiple combinations of ranks are now tested to prevent such regressions to ever happen again. Finally, for the new manual validation plan, the idea will be to use a theme and make sure people will not all order things in different way. Appologies for the mess this caused...
parent
c17c754d
Loading
Loading
Pipeline
#30117
passed
with stages
in
3 minutes and 29 seconds
Loading
Please register or sign in to comment