Skip to content

Commit

Permalink
Allow count to be 0
Browse files Browse the repository at this point in the history
  • Loading branch information
John Crepezzi committed Mar 26, 2010
1 parent 3983c95 commit 3c0ff00
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ice_cube/rule.rb
Expand Up @@ -55,7 +55,7 @@ def until(until_date)

# set the number of occurrences after which this rule is no longer effective
def count(count)
raise ArgumentError.new('Argument must be a positive integer') unless Integer(count) && count > 0 #todo - maybe allow count to be 0
raise ArgumentError.new('Argument must be a positive integer') unless Integer(count) && count >= 0
@occurrence_count = count
self
end
Expand Down
7 changes: 7 additions & 0 deletions spec/examples/ice_cube_spec.rb
Expand Up @@ -107,4 +107,11 @@
dates.each { |date| date.sec == 30 }
end

it 'ensure that when count on a rule is set to 0, 0 occurrences come back' do
start_date = DAY
schedule = Schedule.new(start_date)
schedule.add_recurrence_rule Rule.daily.count(0)
schedule.all_occurrences.should == []
end

end

0 comments on commit 3c0ff00

Please sign in to comment.