Permalink
Browse files

fixing problem caused by adding a skip mark

  • Loading branch information...
1 parent 8007840 commit e498ae2034da2ba445dcb762c26ffc68c9f3a22d @ryanb committed Sep 11, 2009
Showing with 8 additions and 1 deletion.
  1. +1 −1 app/models/stamp.rb
  2. +7 −0 spec/models/stamp_spec.rb
View
@@ -70,7 +70,7 @@ def track_month_points(tracker, date)
if finished
0
elsif mark_on_day(day)
- finished = true if last_mark.marked_on <= day
+ finished = true if last_mark.nil? || last_mark.marked_on <= day
points = mark_on_day(day).skip? ? tracker.skip : tracker.mark
update_attribute(:score_cache, tracker.score) if finished
points
@@ -70,6 +70,13 @@
@stamp.reload.month_points(Date.new(2009, 4)).should == [1] + [0]*29
@stamp.score_cache.should == 1
end
+
+ it "should work with just one skip" do
+ Mark.delete_all
+ @stamp.marks.create!(:marked_on => "2009-04-02", :skip => true)
+ @stamp.reload.month_points(Date.new(2009, 4)).should == [0]*30
+ @stamp.score_cache.should == 0
+ end
end
it "should use score cache if there is one" do

0 comments on commit e498ae2

Please sign in to comment.