ri_cal 0.5.3 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -55,27 +55,20 @@ TEXT
55
55
  result.should == Fr13UnboundedZuluExpectedFive
56
56
  end
57
57
 
58
- end
59
- end
60
-
61
- describe ".occurrences" do
62
- before(:each) do
63
- @it = RiCal.parse_string(Fr13Unbounded_Zulu).first
64
- end
65
-
66
- describe "with :starting specified" do
67
- it "should exclude dates before :starting" do
68
- result = @it.occurrences(:starting => Fr13UnboundedZuluExpectedFive[1].dtstart,
69
- :before => Fr13UnboundedZuluExpectedFive[-1].dtstart)
70
- result.map{|o|o.dtstart}.should == Fr13UnboundedZuluExpectedFive[1..-2].map{|e| e.dtstart}
58
+ describe "with :starting specified" do
59
+ it "should exclude dates before :starting" do
60
+ result = @it.occurrences(:starting => Fr13UnboundedZuluExpectedFive[1].dtstart,
61
+ :before => Fr13UnboundedZuluExpectedFive[-1].dtstart)
62
+ result.map{|o|o.dtstart}.should == Fr13UnboundedZuluExpectedFive[1..-2].map{|e| e.dtstart}
63
+ end
71
64
  end
72
- end
73
65
 
74
- describe "with :before specified" do
75
- it "should exclude dates after :before" do
76
- result = @it.occurrences(:before => Fr13UnboundedZuluExpectedFive[3].dtstart,
77
- :count => 5)
78
- result.map{|o|o.dtstart}.should == Fr13UnboundedZuluExpectedFive[0..2].map{|e| e.dtstart}
66
+ describe "with :before specified" do
67
+ it "should exclude dates after :before" do
68
+ result = @it.occurrences(:before => Fr13UnboundedZuluExpectedFive[3].dtstart,
69
+ :count => 5)
70
+ result.map{|o|o.dtstart}.should == Fr13UnboundedZuluExpectedFive[0..2].map{|e| e.dtstart}
71
+ end
79
72
  end
80
73
  end
81
74
  end
@@ -99,6 +92,336 @@ TEXT
99
92
 
100
93
  end
101
94
  end
95
+
96
+ describe "#zulu_occurrence_range" do
97
+ context "For an unbounded recurring event" do
98
+ before(:each) do
99
+ @event = RiCal.Event do |e|
100
+ e.dtstart = "TZID=America/New_York:20090525T143500"
101
+ e.dtend = "TZID=America/New_York:20090525T153500"
102
+ e.add_rrule("FREQ=DAILY")
103
+ end
104
+ end
105
+
106
+ it "should not be bounded" do
107
+ @event.should_not be_bounded
108
+ end
109
+
110
+ it "should return an array with the first dtstart and nil" do
111
+ @event.zulu_occurrence_range.should == [DateTime.civil(2009,5,25,18,35,00, 0), nil]
112
+ end
113
+ end
114
+
115
+ context "For a bounded recurring event" do
116
+ before(:each) do
117
+ @event = RiCal.Event do |e|
118
+ e.dtstart = "TZID=America/New_York:20090525T143500"
119
+ e.dtend = "TZID=America/New_York:20090525T153500"
120
+ e.add_rrule("FREQ=DAILY;COUNT=3")
121
+ end
122
+ end
123
+
124
+ it "should return an array with the first dtstart last dtend converted to utc" do
125
+ @event.zulu_occurrence_range.should == [DateTime.civil(2009,5,25,18,35,00, 0), DateTime.civil(2009,5,27,19,35,00, 0)]
126
+ end
127
+ end
128
+
129
+ context "For an event with no recurrence rules" do
130
+ context "with a non-floating dtstart and dtend" do
131
+ before(:each) do
132
+ @event = RiCal.Event do |e|
133
+ e.dtstart = "TZID=America/New_York:20090525T143500"
134
+ e.dtend = "TZID=America/New_York:20090525T153500"
135
+ end
136
+ end
137
+
138
+ it "should return an array with dtstart and dtend converted to zulu time" do
139
+ @event.zulu_occurrence_range.should == [DateTime.civil(2009,5,25,18,35,00, 0), DateTime.civil(2009,5,25,19,35,00, 0)]
140
+ end
141
+ end
142
+ context "with a floating dtstart and dtend" do
143
+ before(:each) do
144
+ @event = RiCal.Event do |e|
145
+ e.dtstart = "20090525T143500"
146
+ e.dtend = "20090525T153500"
147
+ end
148
+ end
149
+
150
+ it "should return an array with dtstart in the first timezone and dtend in the last time zone converted to zulu time" do
151
+ @event.zulu_occurrence_range.should == [DateTime.civil(2009,5,25,2,35,00, 0), DateTime.civil(2009,5,26,3,35,00, 0)]
152
+ end
153
+ end
154
+ end
155
+ end
156
+
157
+ context "Ticket #4 from paulsm" do
158
+ it "should produce 4 occurrences" do
159
+ cal = RiCal.parse_string rectify_ical <<-ENDCAL
160
+ BEGIN:VCALENDAR
161
+ METHOD:PUBLISH
162
+ PRODID:-//Apple Inc.//iCal 3.0//EN
163
+ CALSCALE:GREGORIAN
164
+ X-WR-CALNAME:Australian32Holidays
165
+ X-WR-CALDESC:Australian Public Holidays. Compiled from http://www.indust
166
+ rialrelations.nsw.gov.au/holidays/default.html and the links for the oth
167
+ er states at the bottom of that page
168
+ X-WR-RELCALID:AC1E4CE8-6690-49F6-A144-2F8891DFFD8D
169
+ VERSION:2.0
170
+ X-WR-TIMEZONE:Australia/Sydney
171
+ BEGIN:VEVENT
172
+ SEQUENCE:8
173
+ TRANSP:OPAQUE
174
+ UID:5B5579F3-2137-11D7-B491-00039301B0C2
175
+ DTSTART;VALUE=DATE:20020520
176
+ DTSTAMP:20060602T045619Z
177
+ SUMMARY:Adelaide Cup Carnival and Volunteers Day (SA)
178
+ EXDATE;VALUE=DATE:20060515
179
+ CREATED:20080916T000924Z
180
+ DTEND;VALUE=DATE:20020521
181
+ RRULE:FREQ=YEARLY;INTERVAL=1;UNTIL=20070520;BYMONTH=5;BYDAY=3MO
182
+ END:VEVENT
183
+ END:VCALENDAR
184
+ ENDCAL
185
+ cal.first.events.first.occurrences.length.should == 4
186
+ end
187
+ end
188
+
189
+ context "Ticket #2 from paulsm" do
190
+ before(:each) do
191
+ cals = RiCal.parse_string rectify_ical <<-ENDCAL
192
+ BEGIN:VCALENDAR
193
+ X-WR-TIMEZONE:America/New_York
194
+ PRODID:-//Apple Inc.//iCal 3.0//EN
195
+ CALSCALE:GREGORIAN
196
+ X-WR-CALNAME:test
197
+ VERSION:2.0
198
+ X-WR-RELCALID:1884C7F8-BC8E-457F-94AC-297871967D5E
199
+ X-APPLE-CALENDAR-COLOR:#2CA10B
200
+ BEGIN:VTIMEZONE
201
+ TZID:US/Eastern
202
+ BEGIN:DAYLIGHT
203
+ TZOFFSETFROM:-0500
204
+ TZOFFSETTO:-0400
205
+ DTSTART:20070311T020000
206
+ RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
207
+ TZNAME:EDT
208
+ END:DAYLIGHT
209
+ BEGIN:STANDARD
210
+ TZOFFSETFROM:-0400
211
+ TZOFFSETTO:-0500
212
+ DTSTART:20071104T020000
213
+ RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
214
+ TZNAME:EST
215
+ END:STANDARD
216
+ END:VTIMEZONE
217
+ BEGIN:VEVENT
218
+ SEQUENCE:5
219
+ TRANSP:OPAQUE
220
+ UID:00481E53-9258-4EA7-9F8D-947D3041A3F2
221
+ DTSTART;TZID=US/Eastern:20090224T090000
222
+ DTSTAMP:20090225T000908Z
223
+ SUMMARY:Test Event
224
+ CREATED:20090225T000839Z
225
+ DTEND;TZID=US/Eastern:20090224T100000
226
+ RRULE:FREQ=DAILY;INTERVAL=1;UNTIL=20090228T045959Z
227
+ END:VEVENT
228
+ END:VCALENDAR
229
+ ENDCAL
230
+ @event = cals.first.events.first
231
+ end
232
+
233
+
234
+ it "the event should be enumerable" do
235
+ lambda {@event.occurrences}.should_not raise_error
236
+ end
237
+ end
238
+
239
+ context "Lighthouse bug #3" do
240
+ before(:each) do
241
+ cals = RiCal.parse_string rectify_ical <<-ENDCAL
242
+ BEGIN:VCALENDAR
243
+ VERSION:2.0
244
+ PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN
245
+ BEGIN:VTIMEZONE
246
+ TZID:/mozilla.org/20070129_1/Europe/Paris
247
+ X-LIC-LOCATION:Europe/Paris
248
+ BEGIN:DAYLIGHT
249
+ TZOFFSETFROM:+0100
250
+ TZOFFSETTO:+0200
251
+ TZNAME:CEST
252
+ DTSTART:19700329T020000
253
+ RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=3
254
+ END:DAYLIGHT
255
+ BEGIN:STANDARD
256
+ TZOFFSETFROM:+0200
257
+ TZOFFSETTO:+0100
258
+ TZNAME:CET
259
+ DTSTART:19701025T030000
260
+ RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=10
261
+ END:STANDARD
262
+ END:VTIMEZONE
263
+ BEGIN:VEVENT
264
+ CREATED:20070606T141629Z
265
+ LAST-MODIFIED:20070606T154611Z
266
+ DTSTAMP:20070607T120859Z
267
+ UID:5d1ae55f-3910-4de9-8b65-d652768fb2f2
268
+ SUMMARY:Lundi de Pâques
269
+ DTSTART;VALUE=DATE;TZID=/mozilla.org/20070129_1/Europe/Paris:20070409
270
+ DTEND;VALUE=DATE;TZID=/mozilla.org/20070129_1/Europe/Paris:20070410
271
+ CATEGORIES:Jours fériés
272
+ END:VEVENT
273
+ END:VCALENDAR
274
+ ENDCAL
275
+ @event = cals.first.events.first
276
+ end
277
+
278
+ it "should be able to enumerate occurrences" do
279
+ @event.occurrences.should == [@event]
280
+ end
281
+ end
282
+
283
+ context "An event with a DATE dtstart, Ticket #6" do
284
+ before(:each) do
285
+ cal = RiCal.parse_string rectify_ical <<-ENDCAL
286
+ BEGIN:VCALENDAR
287
+ PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN
288
+ VERSION:2.0
289
+ BEGIN:VEVENT
290
+ CREATED:20090520T092032Z
291
+ LAST-MODIFIED:20090520T092052Z
292
+ DTSTAMP:20090520T092032Z
293
+ UID:d41c124a-65c3-400e-bd04-1d2ee7b98352
294
+ SUMMARY:event2
295
+ RRULE:FREQ=MONTHLY;INTERVAL=1
296
+ DTSTART;VALUE=DATE:20090603
297
+ DTEND;VALUE=DATE:20090604
298
+ TRANSP:TRANSPARENT
299
+ END:VEVENT
300
+ END:VCALENDAR
301
+ ENDCAL
302
+ @occurrences = cal.first.events.first.occurrences(
303
+ :after => Date.parse('01/01/1990'),
304
+ :before => Date.parse("01/01/2010")
305
+ )
306
+ end
307
+
308
+ it "should produce the right dtstart values" do
309
+ @occurrences.map {|o| o.dtstart}.should == [
310
+ Date.parse("2009-06-03"),
311
+ Date.parse("2009-07-03"),
312
+ Date.parse("2009-08-03"),
313
+ Date.parse("2009-09-03"),
314
+ Date.parse("2009-10-03"),
315
+ Date.parse("2009-11-03"),
316
+ Date.parse("2009-12-03")
317
+ ]
318
+ end
319
+
320
+ it "should produce events whose dtstarts are all dates" do
321
+ @occurrences.all? {|o| o.dtstart.class == ::Date}.should be_true
322
+ end
323
+
324
+ it "should produce the right dtend values" do
325
+ @occurrences.map {|o| o.dtend}.should == [
326
+ Date.parse("2009-06-04"),
327
+ Date.parse("2009-07-04"),
328
+ Date.parse("2009-08-04"),
329
+ Date.parse("2009-09-04"),
330
+ Date.parse("2009-10-04"),
331
+ Date.parse("2009-11-04"),
332
+ Date.parse("2009-12-04")
333
+ ]
334
+ end
335
+
336
+ it "should produce events whose dtstends are all dates" do
337
+ @occurrences.all? {|o| o.dtend.class == ::Date}.should be_true
338
+ end
339
+ end
340
+ context "bounded? bug" do
341
+ before(:each) do
342
+ events = RiCal.parse_string rectify_ical <<-ENDCAL
343
+ BEGIN:VEVENT
344
+ EXDATE:20090114T163000
345
+ EXDATE:20090128T163000
346
+ EXDATE:20090121T163000
347
+ EXDATE:20090211T163000
348
+ EXDATE:20090204T163000
349
+ EXDATE:20090218T163000
350
+ TRANSP:OPAQUE
351
+ DTSTAMP;VALUE=DATE-TIME:20090107T024340Z
352
+ CREATED;VALUE=DATE-TIME:20090107T024012Z
353
+ DTEND;TZID=US/Mountain;VALUE=DATE-TIME:20090114T180000
354
+ DTSTART;TZID=US/Mountain;VALUE=DATE-TIME:20090114T163000
355
+ UID:15208112-E0FA-4A7C-954C-CFDF19D1B0E7
356
+ RRULE:FREQ=WEEKLY;INTERVAL=1;UNTIL=20090219T065959Z
357
+ SUMMARY:Wild Rose XC/Skate Training Series
358
+ SEQUENCE:11
359
+ LOCATION:Mountain Dell Golf Course
360
+ END:VEVENT
361
+ ENDCAL
362
+ @event = events.first
363
+ end
364
+
365
+ it "should be able to enumerate occurrences" do
366
+ @event.should be_bounded
367
+ end
368
+ end
369
+
370
+ context "EXDATES with timezones bug" do
371
+ before(:each) do
372
+ cals = RiCal.parse_string rectify_ical <<-ENDCAL
373
+ BEGIN:VCALENDAR
374
+ METHOD:PUBLISH
375
+ PRODID:-//Apple Inc.//iCal 3.0//EN
376
+ CALSCALE:GREGORIAN
377
+ X-WR-CALNAME:Utah Cycling
378
+ X-WR-RELCALID:BF579011-36BF-49C6-8C7D-E96F03DE8055
379
+ VERSION:2.0
380
+ X-WR-TIMEZONE:US/Mountain
381
+ BEGIN:VTIMEZONE
382
+ TZID:US/Mountain
383
+ BEGIN:DAYLIGHT
384
+ TZOFFSETFROM:-0700
385
+ TZOFFSETTO:-0600
386
+ DTSTART:20070311T020000
387
+ RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
388
+ TZNAME:MDT
389
+ END:DAYLIGHT
390
+ BEGIN:STANDARD
391
+ TZOFFSETFROM:-0600
392
+ TZOFFSETTO:-0700
393
+ DTSTART:20071104T020000
394
+ RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
395
+ TZNAME:MST
396
+ END:STANDARD
397
+ END:VTIMEZONE
398
+ BEGIN:VEVENT
399
+ SEQUENCE:11
400
+ TRANSP:OPAQUE
401
+ UID:15208112-E0FA-4A7C-954C-CFDF19D1B0E7
402
+ DTSTART;TZID=US/Mountain:20090114T163000
403
+ DTSTAMP:20090107T024340Z
404
+ SUMMARY:Wild Rose XC/Skate Training Series
405
+ EXDATE;TZID=US/Mountain:20090114T163000
406
+ EXDATE;TZID=US/Mountain:20090128T163000
407
+ EXDATE;TZID=US/Mountain:20090121T163000
408
+ EXDATE;TZID=US/Mountain:20090211T163000
409
+ EXDATE;TZID=US/Mountain:20090204T163000
410
+ EXDATE;TZID=US/Mountain:20090218T163000
411
+ CREATED:20090107T024012Z
412
+ DTEND;TZID=US/Mountain:20090114T180000
413
+ LOCATION:Mountain Dell Golf Course
414
+ RRULE:FREQ=WEEKLY;INTERVAL=1;UNTIL=20090219T065959Z
415
+ END:VEVENT
416
+ END:VCALENDAR
417
+ ENDCAL
418
+ @event = cals.first.events.first
419
+ end
420
+
421
+ it "should have no occurrences" do
422
+ @event.occurrences.length.should == 0
423
+ end
424
+ end
102
425
  end
103
426
 
104
427
  describe RiCal::OccurrenceEnumerator::OccurrenceMerger do
@@ -157,7 +480,7 @@ describe RiCal::OccurrenceEnumerator::OccurrenceMerger do
157
480
  end
158
481
  end
159
482
  end
160
-
483
+
161
484
  describe "#zulu_occurrence_range" do
162
485
  end
163
486
 
@@ -242,332 +565,9 @@ describe RiCal::OccurrenceEnumerator::OccurrenceMerger do
242
565
  end
243
566
  end
244
567
 
245
- context "Ticket #4 from paulsm" do
246
- it "should produce 4 occurrences" do
247
- cal = RiCal.parse_string <<ENDCAL
248
- BEGIN:VCALENDAR
249
- METHOD:PUBLISH
250
- PRODID:-//Apple Inc.//iCal 3.0//EN
251
- CALSCALE:GREGORIAN
252
- X-WR-CALNAME:Australian32Holidays
253
- X-WR-CALDESC:Australian Public Holidays. Compiled from http://www.indust
254
- rialrelations.nsw.gov.au/holidays/default.html and the links for the oth
255
- er states at the bottom of that page
256
- X-WR-RELCALID:AC1E4CE8-6690-49F6-A144-2F8891DFFD8D
257
- VERSION:2.0
258
- X-WR-TIMEZONE:Australia/Sydney
259
- BEGIN:VEVENT
260
- SEQUENCE:8
261
- TRANSP:OPAQUE
262
- UID:5B5579F3-2137-11D7-B491-00039301B0C2
263
- DTSTART;VALUE=DATE:20020520
264
- DTSTAMP:20060602T045619Z
265
- SUMMARY:Adelaide Cup Carnival and Volunteers Day (SA)
266
- EXDATE;VALUE=DATE:20060515
267
- CREATED:20080916T000924Z
268
- DTEND;VALUE=DATE:20020521
269
- RRULE:FREQ=YEARLY;INTERVAL=1;UNTIL=20070520;BYMONTH=5;BYDAY=3MO
270
- END:VEVENT
271
- END:VCALENDAR
272
- ENDCAL
273
- cal.first.events.first.occurrences.length.should == 4
274
- end
275
- end
276
-
277
- context "Ticket #2 from paulsm" do
278
- before(:each) do
279
- cals = RiCal.parse_string <<ENDCAL
280
- BEGIN:VCALENDAR
281
- X-WR-TIMEZONE:America/New_York
282
- PRODID:-//Apple Inc.//iCal 3.0//EN
283
- CALSCALE:GREGORIAN
284
- X-WR-CALNAME:test
285
- VERSION:2.0
286
- X-WR-RELCALID:1884C7F8-BC8E-457F-94AC-297871967D5E
287
- X-APPLE-CALENDAR-COLOR:#2CA10B
288
- BEGIN:VTIMEZONE
289
- TZID:US/Eastern
290
- BEGIN:DAYLIGHT
291
- TZOFFSETFROM:-0500
292
- TZOFFSETTO:-0400
293
- DTSTART:20070311T020000
294
- RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
295
- TZNAME:EDT
296
- END:DAYLIGHT
297
- BEGIN:STANDARD
298
- TZOFFSETFROM:-0400
299
- TZOFFSETTO:-0500
300
- DTSTART:20071104T020000
301
- RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
302
- TZNAME:EST
303
- END:STANDARD
304
- END:VTIMEZONE
305
- BEGIN:VEVENT
306
- SEQUENCE:5
307
- TRANSP:OPAQUE
308
- UID:00481E53-9258-4EA7-9F8D-947D3041A3F2
309
- DTSTART;TZID=US/Eastern:20090224T090000
310
- DTSTAMP:20090225T000908Z
311
- SUMMARY:Test Event
312
- CREATED:20090225T000839Z
313
- DTEND;TZID=US/Eastern:20090224T100000
314
- RRULE:FREQ=DAILY;INTERVAL=1;UNTIL=20090228T045959Z
315
- END:VEVENT
316
- END:VCALENDAR
317
- ENDCAL
318
- @event = cals.first.events.first
319
- end
320
568
 
321
569
 
322
- it "the event should be enumerable" do
323
- lambda {@event.occurrences}.should_not raise_error
324
- end
325
- end
326
570
 
327
- context "Lighthouse bug #3" do
328
- before(:each) do
329
- cals = RiCal.parse_string <<ENDCAL
330
- BEGIN:VCALENDAR
331
- VERSION:2.0
332
- PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN
333
- BEGIN:VTIMEZONE
334
- TZID:/mozilla.org/20070129_1/Europe/Paris
335
- X-LIC-LOCATION:Europe/Paris
336
- BEGIN:DAYLIGHT
337
- TZOFFSETFROM:+0100
338
- TZOFFSETTO:+0200
339
- TZNAME:CEST
340
- DTSTART:19700329T020000
341
- RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=3
342
- END:DAYLIGHT
343
- BEGIN:STANDARD
344
- TZOFFSETFROM:+0200
345
- TZOFFSETTO:+0100
346
- TZNAME:CET
347
- DTSTART:19701025T030000
348
- RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=10
349
- END:STANDARD
350
- END:VTIMEZONE
351
- BEGIN:VEVENT
352
- CREATED:20070606T141629Z
353
- LAST-MODIFIED:20070606T154611Z
354
- DTSTAMP:20070607T120859Z
355
- UID:5d1ae55f-3910-4de9-8b65-d652768fb2f2
356
- SUMMARY:Lundi de Pâques
357
- DTSTART;VALUE=DATE;TZID=/mozilla.org/20070129_1/Europe/Paris:20070409
358
- DTEND;VALUE=DATE;TZID=/mozilla.org/20070129_1/Europe/Paris:20070410
359
- CATEGORIES:Jours fériés
360
- END:VEVENT
361
- END:VCALENDAR
362
- ENDCAL
363
- @event = cals.first.events.first
364
- end
365
-
366
- it "should be able to enumerate occurrences" do
367
- @event.occurrences.should == [@event]
368
- end
369
- end
370
-
371
- context "An event with a DATE dtstart, Ticket #6" do
372
- before(:each) do
373
- cal = RiCal.parse_string <<ENDCAL
374
- BEGIN:VCALENDAR
375
- PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN
376
- VERSION:2.0
377
- BEGIN:VEVENT
378
- CREATED:20090520T092032Z
379
- LAST-MODIFIED:20090520T092052Z
380
- DTSTAMP:20090520T092032Z
381
- UID:d41c124a-65c3-400e-bd04-1d2ee7b98352
382
- SUMMARY:event2
383
- RRULE:FREQ=MONTHLY;INTERVAL=1
384
- DTSTART;VALUE=DATE:20090603
385
- DTEND;VALUE=DATE:20090604
386
- TRANSP:TRANSPARENT
387
- END:VEVENT
388
- END:VCALENDAR
389
- ENDCAL
390
- @occurrences = cal.first.events.first.occurrences(
391
- :after => Date.parse('01/01/1990'),
392
- :before => Date.parse("01/01/2010")
393
- )
394
- end
395
-
396
- it "should produce the right dtstart values" do
397
- @occurrences.map {|o| o.dtstart}.should == [
398
- Date.parse("2009-06-03"),
399
- Date.parse("2009-07-03"),
400
- Date.parse("2009-08-03"),
401
- Date.parse("2009-09-03"),
402
- Date.parse("2009-10-03"),
403
- Date.parse("2009-11-03"),
404
- Date.parse("2009-12-03")
405
- ]
406
- end
407
-
408
- it "should produce events whose dtstarts are all dates" do
409
- @occurrences.all? {|o| o.dtstart.class == ::Date}.should be_true
410
- end
411
-
412
- it "should produce the right dtend values" do
413
- @occurrences.map {|o| o.dtend}.should == [
414
- Date.parse("2009-06-04"),
415
- Date.parse("2009-07-04"),
416
- Date.parse("2009-08-04"),
417
- Date.parse("2009-09-04"),
418
- Date.parse("2009-10-04"),
419
- Date.parse("2009-11-04"),
420
- Date.parse("2009-12-04")
421
- ]
422
- end
423
571
 
424
- it "should produce events whose dtstends are all dates" do
425
- @occurrences.all? {|o| o.dtend.class == ::Date}.should be_true
426
- end
427
- end
428
- context "bounded? bug" do
429
- before(:each) do
430
- events = RiCal.parse_string rectify_ical <<-ENDCAL
431
- BEGIN:VEVENT
432
- EXDATE:20090114T163000
433
- EXDATE:20090128T163000
434
- EXDATE:20090121T163000
435
- EXDATE:20090211T163000
436
- EXDATE:20090204T163000
437
- EXDATE:20090218T163000
438
- TRANSP:OPAQUE
439
- DTSTAMP;VALUE=DATE-TIME:20090107T024340Z
440
- CREATED;VALUE=DATE-TIME:20090107T024012Z
441
- DTEND;TZID=US/Mountain;VALUE=DATE-TIME:20090114T180000
442
- DTSTART;TZID=US/Mountain;VALUE=DATE-TIME:20090114T163000
443
- UID:15208112-E0FA-4A7C-954C-CFDF19D1B0E7
444
- RRULE:FREQ=WEEKLY;INTERVAL=1;UNTIL=20090219T065959Z
445
- SUMMARY:Wild Rose XC/Skate Training Series
446
- SEQUENCE:11
447
- LOCATION:Mountain Dell Golf Course
448
- END:VEVENT
449
- ENDCAL
450
- @event = events.first
451
- end
452
-
453
- it "should be able to enumerate occurrences" do
454
- @event.should be_bounded
455
- end
456
- end
457
-
458
- context "EXDATES with timezones bug" do
459
- before(:each) do
460
- cals = RiCal.parse_string rectify_ical <<-ENDCAL
461
- BEGIN:VCALENDAR
462
- METHOD:PUBLISH
463
- PRODID:-//Apple Inc.//iCal 3.0//EN
464
- CALSCALE:GREGORIAN
465
- X-WR-CALNAME:Utah Cycling
466
- X-WR-RELCALID:BF579011-36BF-49C6-8C7D-E96F03DE8055
467
- VERSION:2.0
468
- X-WR-TIMEZONE:US/Mountain
469
- BEGIN:VTIMEZONE
470
- TZID:US/Mountain
471
- BEGIN:DAYLIGHT
472
- TZOFFSETFROM:-0700
473
- TZOFFSETTO:-0600
474
- DTSTART:20070311T020000
475
- RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
476
- TZNAME:MDT
477
- END:DAYLIGHT
478
- BEGIN:STANDARD
479
- TZOFFSETFROM:-0600
480
- TZOFFSETTO:-0700
481
- DTSTART:20071104T020000
482
- RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
483
- TZNAME:MST
484
- END:STANDARD
485
- END:VTIMEZONE
486
- BEGIN:VEVENT
487
- SEQUENCE:11
488
- TRANSP:OPAQUE
489
- UID:15208112-E0FA-4A7C-954C-CFDF19D1B0E7
490
- DTSTART;TZID=US/Mountain:20090114T163000
491
- DTSTAMP:20090107T024340Z
492
- SUMMARY:Wild Rose XC/Skate Training Series
493
- EXDATE;TZID=US/Mountain:20090114T163000
494
- EXDATE;TZID=US/Mountain:20090128T163000
495
- EXDATE;TZID=US/Mountain:20090121T163000
496
- EXDATE;TZID=US/Mountain:20090211T163000
497
- EXDATE;TZID=US/Mountain:20090204T163000
498
- EXDATE;TZID=US/Mountain:20090218T163000
499
- CREATED:20090107T024012Z
500
- DTEND;TZID=US/Mountain:20090114T180000
501
- LOCATION:Mountain Dell Golf Course
502
- RRULE:FREQ=WEEKLY;INTERVAL=1;UNTIL=20090219T065959Z
503
- END:VEVENT
504
- END:VCALENDAR
505
- ENDCAL
506
- @event = cals.first.events.first
507
- end
508
-
509
- it "should have no occurrences" do
510
- @event.occurrences.length.should == 0
511
- end
512
- end
513
-
514
-
515
- describe "#zulu_occurrence_range" do
516
- context "For an unbounded recurring event" do
517
- before(:each) do
518
- @event = RiCal.Event do |e|
519
- e.dtstart = "TZID=America/New_York:20090525T143500"
520
- e.dtend = "TZID=America/New_York:20090525T153500"
521
- e.add_rrule("FREQ=DAILY")
522
- end
523
-
524
- it "should return an array with the first dtstart and nil" do
525
- @event.zulu_occurrence_range.should == [DateTime.civil(2009,5,25,18,35,00, 0), nil]
526
- end
527
- end
528
- end
529
-
530
- context "For a bounded recurring event" do
531
- before(:each) do
532
- @event = RiCal.Event do |e|
533
- e.dtstart = "TZID=America/New_York:20090525T143500"
534
- e.dtend = "TZID=America/New_York:20090525T153500"
535
- e.add_rrule("FREQ=DAILY;COUNT=3")
536
- end
537
-
538
- it "should return an array with the first dtstart last dtend converted to utc" do
539
- @event.zulu_occurrence_range.should == [DateTime.civil(2009,5,25,18,35,00, 0), DateTime.civil(2009,5,27,19,35,00, 0)]
540
- end
541
- end
542
- end
543
-
544
- context "For an event with no recurrence rules" do
545
- context "with a non-floating dtstart and dtend" do
546
- before(:each) do
547
- @event = RiCal.Event do |e|
548
- e.dtstart = "TZID=America/New_York:20090525T143500"
549
- e.dtend = "TZID=America/New_York:20090525T153500"
550
- end
551
- end
552
-
553
- it "should return an array with dtstart and dtend converted to zulu time" do
554
- @event.zulu_occurrence_range.should == [DateTime.civil(2009,5,25,18,35,00, 0), DateTime.civil(2009,5,25,19,35,00, 0)]
555
- end
556
- end
557
- context "with a floating dtstart and dtend" do
558
- before(:each) do
559
- @event = RiCal.Event do |e|
560
- e.dtstart = "20090525T143500"
561
- e.dtend = "20090525T153500"
562
- end
563
- end
564
-
565
- it "should return an array with dtstart in the first timezone and dtend in the last time zone converted to zulu time" do
566
- @event.zulu_occurrence_range.should == [DateTime.civil(2009,5,25,2,35,00, 0), DateTime.civil(2009,5,26,3,35,00, 0)]
567
- end
568
- end
569
- end
570
- end
571
-
572
572
 
573
573
  end