Conversation
…ation start and end dates
…values and create reservation instances
…ost instance variable in reservation an admin spec.
…ation instances array returns booked room id
…ects with a specifc date, tests pass for intersect and no date intersects
…ion to existing reservations prevents double booking
…ing with existing reservations
… to new room for reservation attempts to rooms that are already booked
…ot reassign new booking to another room
… block, most testing completed
…m ids, all tests all passing
HotelWhat We're Looking For
|
| raise ArgumentError.new("#{room_id} is booked for these dates") | ||
| end | ||
|
|
||
| if available_rooms.count == 0 |
There was a problem hiding this comment.
Ummm.. if there were no rooms then available_rooms would not include room_id.
| @reservations.each do |reservation| | ||
| valid_check_in = check_in.between?(reservation.start_date, (reservation.end_date - 1)) | ||
|
|
||
| valid_check_out = check_out.between?((reservation.start_date + 1), reservation.end_date) |
There was a problem hiding this comment.
What about if the reservation occurs entirely between check_in and check_out?
| @reservations << Reservation.new(check_in, check_out, room_id) | ||
| end | ||
|
|
||
| def available_rooms(check_in, check_out) |
There was a problem hiding this comment.
To have wave 3 complete you may also need to check the blocks, or make sure add_reservation considers blocks.
| @@ -0,0 +1,47 @@ | |||
| require 'date' | |||
|
|
|||
| class Reservation | |||
There was a problem hiding this comment.
I would suggest a method in reservation which either takes a Reservation or a date range and returns true if it overlaps with this reservation and false if it does not. It might make the logic easier in Admin.
| @bookings[0].room_id.must_equal 1 | ||
| end | ||
|
|
||
| it "calculates the length of stay" do |
There was a problem hiding this comment.
This is really a test of the Reservation class.
| end | ||
|
|
||
| it "add reservation adds reservation to reservations list" do | ||
| before_rezs = @blockroom_test.reservations.dup |
There was a problem hiding this comment.
I'm unsure why you need to duplicate the array.
Hotel
Congratulations! You're submitting your assignment!
Comprehension Questions