@@ -240,7 +240,7 @@ def get_milestone(milestone_name:)
240
240
end
241
241
242
242
it 'computes the correct dates when the due date is on the verge of a DST day change' do
243
- # DST starts on the last Sunday of March and ends on the last Sunday of October
243
+ # Europe DST starts on the last Sunday of March, and ends on the last Sunday of October
244
244
Time . use_zone ( 'Europe/London' ) do
245
245
due_date = Time . zone . parse ( '2022-03-27 23:00:00Z' )
246
246
options = {
@@ -254,7 +254,7 @@ def get_milestone(milestone_name:)
254
254
end
255
255
256
256
it 'computes the correct dates when the due date is on DST but has no day change' do
257
- # DST starts on the last Sunday of March and ends on the last Sunday of October
257
+ # Europe DST starts on the last Sunday of March, and ends on the last Sunday of October
258
258
Time . use_zone ( 'Europe/London' ) do
259
259
due_date = Time . zone . parse ( '2022-03-26 23:00:00Z' )
260
260
options = {
@@ -267,6 +267,64 @@ def get_milestone(milestone_name:)
267
267
end
268
268
end
269
269
270
+ it 'computes the correct dates when the offset is between DST endings' do
271
+ # Europe DST starts on the last Sunday of March, and ends on the last Sunday of October
272
+ Time . use_zone ( 'Europe/London' ) do
273
+ due_date = Time . zone . parse ( '2022-10-30 23:00:00Z' )
274
+ options = {
275
+ due_on : '2022-10-30T12:00:00Z' ,
276
+ description : "Code freeze: October 30, 2022\n App Store submission: March 19, 2023\n Release: March 25, 2023\n "
277
+ }
278
+
279
+ expect ( client ) . to receive ( :create_milestone ) . with ( test_repo , test_milestone_number , options )
280
+ create_milestone ( due_date : due_date , days_until_submission : 140 , days_until_release : 146 )
281
+ end
282
+ end
283
+
284
+ it 'computes the correct dates when the release and submission dates are at the last day of a DST change' do
285
+ # Europe DST starts on the last Sunday of March, and ends on the last Sunday of October
286
+ Time . use_zone ( 'Europe/London' ) do
287
+ due_date = Time . zone . parse ( '2022-03-27 23:00:00Z' )
288
+ options = {
289
+ due_on : '2022-03-28T12:00:00Z' ,
290
+ description : "Code freeze: March 28, 2022\n App Store submission: October 30, 2022\n Release: October 31, 2022\n "
291
+ }
292
+
293
+ expect ( client ) . to receive ( :create_milestone ) . with ( test_repo , test_milestone_number , options )
294
+ create_milestone ( due_date : due_date , days_until_submission : 216 , days_until_release : 217 )
295
+ end
296
+ end
297
+
298
+ it 'computes the correct dates when the due date is before Europe and USA DST changes and ends inside a DST period on Europe' do
299
+ # USA DST starts on the second Sunday in March. and ends on the first Sunday in November
300
+ # Europe DST starts on the last Sunday of March, and ends on the last Sunday in October
301
+ Time . use_zone ( 'Europe/London' ) do
302
+ due_date = Time . zone . parse ( '2022-03-05 23:00:00Z' )
303
+ options = {
304
+ due_on : '2022-03-05T12:00:00Z' ,
305
+ description : "Code freeze: March 05, 2022\n App Store submission: May 04, 2022\n Release: May 05, 2022\n "
306
+ }
307
+
308
+ expect ( client ) . to receive ( :create_milestone ) . with ( test_repo , test_milestone_number , options )
309
+ create_milestone ( due_date : due_date , days_until_submission : 60 , days_until_release : 61 )
310
+ end
311
+ end
312
+
313
+ it 'computes the correct dates when the due date is before Europe and USA DST changes and ends inside a DST period on USA' do
314
+ # USA DST starts on the second Sunday in March. and ends on the first Sunday in November
315
+ # Europe DST starts on the last Sunday of March, and ends on the last Sunday in October
316
+ Time . use_zone ( 'America/Los_Angeles' ) do
317
+ due_date = Time . zone . parse ( '2022-03-05 23:00:00Z' )
318
+ options = {
319
+ due_on : '2022-03-05T12:00:00Z' ,
320
+ description : "Code freeze: March 05, 2022\n App Store submission: May 04, 2022\n Release: May 05, 2022\n "
321
+ }
322
+
323
+ expect ( client ) . to receive ( :create_milestone ) . with ( test_repo , test_milestone_number , options )
324
+ create_milestone ( due_date : due_date , days_until_submission : 60 , days_until_release : 61 )
325
+ end
326
+ end
327
+
270
328
it 'raises an error if days_until_submission is less than or equal zero' do
271
329
due_date = '2022-10-20T08:00:00Z' . to_time . utc
272
330
expect { create_milestone ( due_date : due_date , days_until_submission : 0 , days_until_release : 5 ) }
0 commit comments