Skip to content

Commit de90d4d

Browse files
committed
GithubHelper: Adds more unit tests to validate the Timezone changes
1 parent b218ccc commit de90d4d

File tree

1 file changed

+60
-2
lines changed

1 file changed

+60
-2
lines changed

spec/github_helper_spec.rb

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def get_milestone(milestone_name:)
240240
end
241241

242242
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
244244
Time.use_zone('Europe/London') do
245245
due_date = Time.zone.parse('2022-03-27 23:00:00Z')
246246
options = {
@@ -254,7 +254,7 @@ def get_milestone(milestone_name:)
254254
end
255255

256256
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
258258
Time.use_zone('Europe/London') do
259259
due_date = Time.zone.parse('2022-03-26 23:00:00Z')
260260
options = {
@@ -267,6 +267,64 @@ def get_milestone(milestone_name:)
267267
end
268268
end
269269

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\nApp Store submission: March 19, 2023\nRelease: 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\nApp Store submission: October 30, 2022\nRelease: 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\nApp Store submission: May 04, 2022\nRelease: 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\nApp Store submission: May 04, 2022\nRelease: 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+
270328
it 'raises an error if days_until_submission is less than or equal zero' do
271329
due_date = '2022-10-20T08:00:00Z'.to_time.utc
272330
expect { create_milestone(due_date: due_date, days_until_submission: 0, days_until_release: 5) }

0 commit comments

Comments
 (0)