Permalink
Browse files

Merge pull request #106 from dhiemstra/reset_rule_endtime

Remove validation when rule until is set to nil
  • Loading branch information...
2 parents 77a6057 + d4f44ef commit 148d3a172579b53829a8ba7a66b0d346e3823090 @seejohnrun committed Oct 19, 2012
Showing with 15 additions and 3 deletions.
  1. +1 −1 lib/ice_cube/validations/until.rb
  2. +1 −1 spec/examples/ice_cube_spec.rb
  3. +13 −1 spec/examples/regression_spec.rb
@@ -12,7 +12,7 @@ def until_time
def until(time)
@until = time
- replace_validations_for(:until, [Validation.new(time)])
+ replace_validations_for(:until, time.nil? ? nil : [Validation.new(time)])
self
end
@@ -808,7 +808,7 @@
rule = IceCube::Rule.daily.until(Time.now + IceCube::ONE_DAY)
rule.to_hash[:until].should_not be_nil
rule.until nil
- rule.to_hash[:until].should be_nil
+ rule.to_hash.should_not have_key(:until)
end
# Full required for rules account for @interval
@@ -114,7 +114,7 @@
it 'should return true if a recurring schedule occurs_between? a time range [#88]' do
start_time = Time.new(2012, 7, 7, 8)
schedule = IceCube::Schedule.new(start_time, :duration => 2 * IceCube::ONE_HOUR)
- schedule.add_recurrence_rule Rule.weekly
+ schedule.add_recurrence_rule IceCube::Rule.weekly
t1 = Time.new(2012, 7, 14, 9)
t2 = Time.new(2012, 7, 14, 11)
schedule.occurring_between?(t1, t2).should be_true
@@ -177,4 +177,16 @@
schedule.first.should == Time.zone.local(2011, 12, 29, 14)
end
+ it 'should not raise an exception after setting the rule until to nil' do
+ rule = IceCube::Rule.daily.until(Time.local(2012, 10, 1))
+ rule.until(nil)
+
+ schedule = IceCube::Schedule.new Time.local(2011, 10, 11, 12)
+ schedule.add_recurrence_rule rule
+
+ lambda {
+ schedule.occurrences_between(Time.local(2012, 1, 1), Time.local(2012, 12, 1))
+ }.should_not raise_error(ArgumentError, 'comparison of Time with nil failed')
+ end
+
end

0 comments on commit 148d3a1

Please sign in to comment.