Skip to content

Instantly share code, notes, and snippets.

@ryaz
Created October 14, 2014 11:13
Show Gist options
  • Save ryaz/0d28bb36b2ede77a5b61 to your computer and use it in GitHub Desktop.
Save ryaz/0d28bb36b2ede77a5b61 to your computer and use it in GitHub Desktop.
Reservation
Write a migration and ActiveRecord model that tracks restaurant reservations. Assume there is a table in your relational database named "reservations". Reservations have a start time, an end time and a table number.
Write some ActiveRecord validations that check new reservations for overbooking of the same table in the restaurant. For example, table #10 cannot have 2 reservations for the same period of time. This validation(s) should check time overlap for both record creation and updates.
Unit tests are a must to make sure your double booking validations are working. (rspec and unittests)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment