Merged
Conversation
We use Zonebie so we are impacted by Europe's changes into and out of Daylight Savings Time as well as ours. Days sometimes have 23 or 25 hours, so account for that in specs by counting time within(60) minutes. Co-authored-by: Jack Ryan <jack.ryan@gsa.gov>
Contributor
|
As an alternative, could we freeze time to a specific point in time that we don't have to deal with changing DST? Personally I find |
Contributor
|
I'd agree. The test can be made to fail reliably with: --- a/spec/jobs/get_usps_proofing_results_job_spec.rb
+++ b/spec/jobs/get_usps_proofing_results_job_spec.rb
@@ -47,6 +47,11 @@ RSpec.shared_examples 'enrollment_with_a_status_update' do |passed:,
end
end
+ before do
+ Time.zone = 'Europe/Vienna'
+ allow(Time.zone).to receive(:now).and_return(Time.zone.parse('2023-11-01T00:20:00Z'))
+ end
+ |
jmhooper
reviewed
Nov 2, 2023
|
|
||
| it 'logs a message with common attributes' do | ||
| freeze_time do | ||
| travel_to Time.zone.parse('2023-11-30T10:00:00Z') do |
Contributor
There was a problem hiding this comment.
I am generally no fan of comments, but I'll suggest either a comment here to explain why we are going to 11/30 or a method that describes that behavior, e.g.
it 'logs a message with common attributes' do
travel_to_stable_daylight_savings_period do
# ...
end
end
# ...
def travel_to_stable_daylight_savings_period
travel_to Time.zone.parse('2023-11-30T10:00:00Z') { yield }
end
Contributor
Author
There was a problem hiding this comment.
I added an explanatory variable in 8522000
jmhooper
approved these changes
Nov 2, 2023
JackRyan1989
approved these changes
Nov 2, 2023
Contributor
JackRyan1989
left a comment
There was a problem hiding this comment.
LGTM! Thanks @soniaconnolly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We use Zonebie so we are impacted by Europe's changes into and out of Daylight Savings Time as well as ours. Days sometimes have 23 or 25 hours, so account for that in specs by counting time within(60) minutes.
Note that we are more than 3 days out from Europe's DST change now, so this test will no longer fail with European time zones - but it would have started failing next week with North American time zones.
Auxilliary note: I would like to make Zonebie print the timezone it is using for our specs to ease debugging of such issues.