File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ module IceCube
5
5
module Validations ::Day
6
6
7
7
def day ( *days )
8
+ days = days . flatten
9
+ return self if days . empty?
8
10
days . flatten . each do |day |
9
11
unless day . is_a? ( Fixnum ) || day . is_a? ( Symbol )
10
12
raise ArgumentError , "expecting Fixnum or Symbol value for day, got #{ day . inspect } "
Original file line number Diff line number Diff line change @@ -102,6 +102,14 @@ module IceCube
102
102
expect { schedule . add_recurrence_rule Rule . weekly . day ( [ "1" , "3" ] ) } . to raise_error
103
103
end
104
104
105
+ it 'should ignore weekday validation when no days are specified' do
106
+ schedule = Schedule . new ( t0 = WEDNESDAY )
107
+ schedule . add_recurrence_rule Rule . weekly ( 2 ) . day ( [ ] )
108
+
109
+ times = schedule . occurrences ( t0 + 3 * ONE_WEEK )
110
+ expect ( times ) . to eq [ t0 , t0 + 2 * ONE_WEEK ]
111
+ end
112
+
105
113
it 'should produce the correct number of days for @interval = 2 with only one day per week' do
106
114
schedule = Schedule . new ( t0 = WEDNESDAY )
107
115
schedule . add_recurrence_rule Rule . weekly ( 2 ) . day ( :wednesday )
You can’t perform that action at this time.
0 commit comments