-
Notifications
You must be signed in to change notification settings - Fork 58
[1229] Seed script generates reservations with start date after due date #1567
Conversation
generate_objs(:generate_reservation, 'reservation', n) | ||
# TODO: remove |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left the below code for review; it's how I tested that my fix was working. I ran the seed script 20 times (generating 2,000 reservations altogether) and didn't get any errors. On master
modified with the same testing code, I got 66 runs with date errors out of 100.
Rubocop is going to fail on the last commit, but only because of the test statements, so I'm going to leave it for now |
Looks great, TimeHelpers for the win. Feel free to remove the testing blocks and we can squash/merge. Nice work! |
166bc03
to
e09f115
Compare
Squashed! |
@@ -279,7 +280,7 @@ def throw_into_past(res) | |||
res.due_date = res.due_date - factor | |||
mark_checked_out res | |||
mark_checked_in(res, res.equipment_model.category.max_checkout_length) | |||
res.save(validate: false) | |||
travel_to(res.start_date) { res.save } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this marks overdue reservations as not overdue and probably messes with the status as well if the reservation is checked in
Never mind, I noticed a problem that applied here while working on #1327. Ready for re-review. |
Great catch, callbacks are nice to keep things sane but they're also easy to forget. Let's re-squash and then we should be good to merge. |
a78efd5
to
6d30de1
Compare
Ready to merge! |
Awesome, merging! Don't forget to update the CHANGELOG in #1548 (I'll stop reminding you after this 😛). |
Resolves #1229, and incidentally #1263 as well.
Note that this is kind of a "band-aid" fix; the script still generates bad dates, but it doesn't save them, instead trying to build the reservation again (which it can do up to 50 times). #474 involves an overhaul of seed script functionality anyway, so I'm okay with this quick fix for now. I'm planning on working on #1327 and then #474 next.