Skip to content
This repository has been archived by the owner on Jul 24, 2020. It is now read-only.

Commit

Permalink
Seed script no longer generates reservations with impossible dates
Browse files Browse the repository at this point in the history
Resolves #1229 and #1263
 - Seed script uses TimeHelpers to save reservations in the past,
   allowing validations to be run on them
  • Loading branch information
Sydney Young committed May 19, 2016
1 parent 5e73c7d commit e09f115
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

require 'ffaker'
require 'ruby-progressbar'
include ActiveSupport::Testing::TimeHelpers

# rubocop:disable Rails/Output

Expand Down Expand Up @@ -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 }
end

# rubocop:disable AbcSize, MethodLength
Expand All @@ -299,10 +300,9 @@ def generate_reservation
checkout_length.days).to_date
res.notes = FFaker::HipsterIpsum.paragraph(8)
res.notes_unsent = [true, false].sample
if rand < PAST_CHANCE
throw_into_past res
return
end

throw_into_past res if rand < PAST_CHANCE

try_again = false
begin
res.save!
Expand Down

0 comments on commit e09f115

Please sign in to comment.