@@ -102,7 +102,14 @@ module IceCube
102
102
RRULE:FREQ=WEEKLY;BYDAY=TH;UNTIL=20130531T100000Z
103
103
ICAL
104
104
105
- ical_string_woth_multiple_exdates = <<-ICAL . gsub ( /^\s */ , '' )
105
+ ical_string_with_time_zones = <<-ICAL . gsub ( /^\s */ , '' )
106
+ DTSTART;TZID=America/Denver:20130731T143000
107
+ DTEND:20130731T153000
108
+ RRULE:FREQ=WEEKLY
109
+ EXDATE;TZID=America/Chicago:20130823T143000
110
+ ICAL
111
+
112
+ ical_string_with_multiple_exdates = <<-ICAL . gsub ( /^\s */ , '' )
106
113
DTSTART;TZID=America/Denver:20130731T143000
107
114
DTEND;TZID=America/Denver:20130731T153000
108
115
RRULE:FREQ=WEEKLY;UNTIL=20140730T203000Z;BYDAY=MO,WE,FR
@@ -125,6 +132,20 @@ def sorted_ical(ical)
125
132
it "loads an ICAL string" do
126
133
expect ( IceCube ::Schedule . from_ical ( ical_string ) ) . to be_a ( IceCube ::Schedule )
127
134
end
135
+ describe "parsing time zones" do
136
+ it "sets the time zone of the start time" do
137
+ schedule = IceCube ::Schedule . from_ical ( ical_string_with_time_zones )
138
+ expect ( schedule . start_time . time_zone ) . to eq ActiveSupport ::TimeZone . new ( "America/Denver" )
139
+ end
140
+ it "sets the time zone of the end time to UTC if none provided" do
141
+ schedule = IceCube ::Schedule . from_ical ( ical_string_with_time_zones )
142
+ expect ( schedule . end_time . time_zone ) . to eq ActiveSupport ::TimeZone . new ( "UTC" )
143
+ end
144
+ it "sets the time zone of the exception times" do
145
+ schedule = IceCube ::Schedule . from_ical ( ical_string_with_time_zones )
146
+ expect ( schedule . exception_times [ 0 ] . time_zone ) . to eq ActiveSupport ::TimeZone . new ( "America/Chicago" )
147
+ end
148
+ end
128
149
end
129
150
130
151
describe "daily frequency" do
@@ -359,7 +380,7 @@ def sorted_ical(ical)
359
380
end
360
381
361
382
it 'handles multiple EXDATE lines' do
362
- schedule = IceCube ::Schedule . from_ical ical_string_woth_multiple_exdates
383
+ schedule = IceCube ::Schedule . from_ical ical_string_with_multiple_exdates
363
384
schedule . exception_times . count . should == 3
364
385
end
365
386
end
0 commit comments