-
Notifications
You must be signed in to change notification settings - Fork 57
refactor complex method available? in ReservationValidations #343
Conversation
unless my tests are way off, this method is at least partially broken, so that needs to be addressed as well |
The instance method for EquipmentModel With a clean db generated from |
@@ -55,6 +55,8 @@ class Reservation < ActiveRecord::Base | |||
scope :missed_requests, lambda {where("approval_status = ? and start_date < ?", 'requested', Time.now.midnight.utc)} | |||
|
|||
scope :for_reserver, lambda { |reserver| where(reserver_id: reserver) } | |||
scope :reserved_in_date_range, lambda { |start_date, end_date| | |||
where("start_date < ? and due_date > ?",end_date, start_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.
please add checks to filter so that it only returns approval_status == 'auto' or 'approved'. your new code already filters that out via the not_returned scope, but I think it would be good to filter here also in case anyone ever calls reserved_in_date_range by itself. another thing I should have considered before, in #297, is setting up a scope for just approval_status == 'auto' or 'approved', and then chaining it onto the other scopes like we're already doing with .recent for example.
looks good to me! |
refactor complex method available? in ReservationValidations
Nice, looks great! Oren Kanner On Mon, Jul 7, 2014 at 12:26 PM, Sylvan Zheng [email protected]
|
No description provided.