Permalink
Browse files

applying first mark if there are multiple marks in the same day

  • Loading branch information...
1 parent cb81c88 commit 2835f80cc6ce82ff8c8939d89cce7d0c709533c5 @ryanb committed Sep 9, 2009
Showing with 10 additions and 1 deletion.
  1. +1 −1 app/models/stamp.rb
  2. +9 −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 mark_on_day(day) == last_mark
+ finished = true if last_mark.marked_on <= day
points = mark_on_day(day).skip? ? tracker.skip : tracker.mark
update_attribute(:score_cache, tracker.score) if finished
points
@@ -61,6 +61,15 @@
@stamp.marks.create!(:marked_on => "2009-04-10", :skip => true)
@stamp.month_points(Date.new(2009, 4)).should == [1, 2] + [0]*28
end
+
+ it "should only take into account first mark if there are multiple on same day" do
+ Mark.delete_all
+ @stamp.marks.create!(:marked_on => "2009-04-01")
+ @stamp.marks.create!(:marked_on => "2009-04-02", :skip => true)
+ @stamp.marks.create!(:marked_on => "2009-04-02")
+ @stamp.reload.month_points(Date.new(2009, 4)).should == [1] + [0]*29
+ @stamp.score_cache.should == 1
+ end
end
it "should use score cache if there is one" do

0 comments on commit 2835f80

Please sign in to comment.