-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ampers - Abinnet #41
base: master
Are you sure you want to change the base?
Ampers - Abinnet #41
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ummm.. if there were no rooms then available_rooms
would not include room_id
.
lib/admin.rb
Outdated
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about if the reservation occurs entirely between check_in
and check_out
?
lib/admin.rb
Outdated
@reservations << Reservation.new(check_in, check_out, room_id) | ||
end | ||
|
||
def available_rooms(check_in, check_out) |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unsure why you need to duplicate the array.
Hotel
Congratulations! You're submitting your assignment!
Comprehension Questions