umts / jobapps

Rails app for job application, interview scheduling, demographic reporting, and application resource configuration.
https://transit-jobapps.admin.umass.edu/
MIT License
5 stars 4 forks source link

Questions do not renumber properly when one is deleted #287

Open Anbranin opened 7 years ago

Anbranin commented 7 years ago

For example, if you have questions 1, 2, 3, 4, 5 and delete question 3, you'll have questions 1,2,4,5 remaining. Thus the next time you try to "move" questions, they'll fail in the spot of the missing number. Re-ordering them when a delete call is made should be sufficient.

dfaulken commented 7 years ago

Looks a lot like it does:

https://github.com/umts/jobapps/blob/master/app/controllers/application_drafts_controller.rb#L31 https://github.com/umts/jobapps/blob/master/app/models/application_draft.rb#L37-L40

Anbranin commented 7 years ago

Oh gosh darnit. Well, this is what happens when you just assume something is a problem because it happened once in production and don't actually look at the code.

werebus commented 7 years ago

Well, I mean, it did happen. In particular, the way that renumbering works, its possible that renumbering could end up partially applied.

So, this isn't a systematic logic error, but it is still a bug.

dfaulken commented 7 years ago

Seems like perhaps a transaction block would be a good way to protect against this.