Conversation
HotelWhat We're Looking For
|
| rooms << Room.new({ | ||
| :room_number => room_number | ||
| }) | ||
| end |
There was a problem hiding this comment.
I think this block makes more sense as a factory method inside Room.
| input = {} | ||
| input[:room_number] = room_number | ||
| input[:start_date] = start_date | ||
| input[:end_date] = end_date |
There was a problem hiding this comment.
Cool use of a hash to keep your code loose! Just as an FYI, keyword parameters do the same thing but keep greater clarity as to what's actually getting passed in!
| results = [] | ||
|
|
||
| @reservations.each do |reservation| | ||
| if reservation.start_date <= search_date && search_date < reservation.end_date |
There was a problem hiding this comment.
So, this expression in the if should probably be the return value of an instance method for the Reservation class.
spec/front_desk_spec.rb
Outdated
|
|
||
| it "raises error if standard reservation conflicts with block reservation" do | ||
| @admin.block_hold(('2018-02-01'),('2018-02-11'),2, "Martinez") | ||
| expect {@admin.reserve_room(1,('2018-02-01'),('2018-02-10'))}.must_raise StandardError |
There was a problem hiding this comment.
I think I see what happened with your code: We expect that people can still reserve rooms inside a block. By this, I mean that if I Devin create a block of four rooms, I don't pay for them all at once. I am telling the hotel "I think I can help you fill these rooms because of my event". Each person in my party still has to make their own reservation after the block is created.
spec/front_desk_spec.rb
Outdated
| # it "raises an error if start date after the end date" do | ||
| # room = @admin.reserve_room(6,('2018-02-05'),('2018-02-03')) | ||
| # expect{room}.must_raise StandardError | ||
| # end |
There was a problem hiding this comment.
Why is this test commented out? It's a super important test!
| end | ||
|
|
||
| def reserve_room(room_number,start_date, end_date) | ||
|
|
There was a problem hiding this comment.
You should be checking here to see if the start_date comes before the end date! Not having this fundamentally breaks a lot of the other code you've written!
spec/front_desk_spec.rb
Outdated
| expect(@admin.search_reserved_by_date('2018-02-05').length).must_equal 3 | ||
| end | ||
|
|
||
| it "returns zero for day of" do |
There was a problem hiding this comment.
I'd specify "date of checkout" in the title here.
|
|
||
| it "allows a reservation to end on the same day another reservation starts" do | ||
| expect(@admin.reserve_room(5,('2018-02-01'),('2018-02-03'))).must_be_kind_of Reservation | ||
| end |
There was a problem hiding this comment.
You are missing important test cases for overlapping reservations! What if the reservation surrounds an existing reservation? What if it's completely inside another reservation?
I'm fairly certain that your code would pass the tests, but you don't ensure that confidence by doing exhaustive testing!
Hotel
Congratulations! You're submitting your assignment!
Comprehension Questions