public
Description: OneBody is web-based software that connects community members, especially churches, on the web.
Homepage: http://beonebody.com
Clone URL: git://github.com/seven1m/onebody.git
Fix birthday_soon? method (Ben Hudson) and fix test.
Tim Morgan (author)
Wed Oct 15 06:14:00 -0700 2008
commit  c30a91d1b0872668341bd9a8edc4c3a781760bc8
tree    023197538c998a869d736ea3211b825df3790be3
parent  e2bd33309e4688a81f2f97fb5c4184b8d446bdd7
...
190
191
192
193
 
194
195
 
196
197
198
...
190
191
192
 
193
194
 
195
196
197
198
0
@@ -190,9 +190,9 @@ class Person < ActiveRecord::Base
0
   
0
   def birthday_soon?
0
     today = Date.today
0
-    birthday and birthday >= today and birthday < (today + BIRTHDAY_SOON_DAYS)
0
+    birthday and ((birthday.yday()+365 - today.yday()).modulo(365) < BIRTHDAY_SOON_DAYS)
0
   end
0
-  
0
+    
0
   def mobile_phone=(phone)
0
     write_attribute :mobile_phone, phone.to_s.digits_only
0
   end
...
110
111
112
113
 
114
115
 
116
117
118
...
110
111
112
 
113
114
 
115
116
117
118
0
@@ -110,9 +110,9 @@ class PersonTest < Test::Unit::TestCase
0
   end
0
   
0
   should "know when a birthday is coming up" do
0
-    people(:tim).update_attributes!(:birthday => Date.today + 5)
0
+    people(:tim).update_attributes!(:birthday => Time.now + 5.days - 27.years)
0
     assert people(:tim).reload.birthday_soon?
0
-    people(:tim).update_attributes!(:birthday => Date.today + BIRTHDAY_SOON_DAYS + 1)
0
+    people(:tim).update_attributes!(:birthday => Time.now - 27.years + (BIRTHDAY_SOON_DAYS + 1).days)
0
     assert !people(:tim).reload.birthday_soon?
0
   end
0
   

Comments