From 0a46babdce9f69a98bbdeb6997d7cebcd6bccd84 Mon Sep 17 00:00:00 2001 From: Cody Herriges Date: Tue, 7 Feb 2012 21:36:35 -0800 Subject: [PATCH] Fix lease return logic. Identified that the logic that the last lease in the file wins when it is actually the last lease to expire. This requires we sort the list of end times and select that last one. --- lib/fission/lease.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fission/lease.rb b/lib/fission/lease.rb index b722705..17b61fb 100644 --- a/lib/fission/lease.rb +++ b/lib/fission/lease.rb @@ -97,7 +97,7 @@ def self.find_by_mac_address(mac_address) if all_response.successful? response = Response.new :code => 0 - response.data = all_response.data.find_all { |l| l.mac_address == mac_address }.last + response.data = all_response.data.find_all { |l| l.mac_address == mac_address }.sort_by { |l| l.end }.last else response = all_response end