Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky test which would fail in certain timezones #555

Merged

Conversation

jsantos
Copy link
Contributor

@jsantos jsantos commented Dec 10, 2020

I'm currently in Singapore (whose timezone is UTC+8), and this test was constantly failing:

Failures:

  1) Audited::Audit.collection_cache_key uses created at
     Failure/Error: expect(Audited::Audit.collection_cache_key).to match(/-20180101\d+$/)

       expected "audited/audits/query-1ae402d409ee3a828c0f94e5cd171ef7-1-20171231160000000000" to match /-20180101\d+$/
       Diff:
       @@ -1 +1 @@
       -/-20180101\d+$/
       +"audited/audits/query-1ae402d409ee3a828c0f94e5cd171ef7-1-20171231160000000000"

     # ./spec/audited/audit_spec.rb:178:in `block (3 levels) in <top (required)>'

Without using Time.zone.parse, the Time.parse method will default to the local timezone, which would cause an error in this specific case (4PM UTC is 12AM SGT).

I'm currently in Singapore (whose timezone is UTC+8), and this test was
constantly failing:

```
Failures:

  1) Audited::Audit.collection_cache_key uses created at
     Failure/Error: expect(Audited::Audit.collection_cache_key).to match(/-20180101\d+$/)

       expected "audited/audits/query-1ae402d409ee3a828c0f94e5cd171ef7-1-20171231160000000000" to match /-20180101\d+$/
       Diff:
       @@ -1 +1 @@
       -/-20180101\d+$/
       +"audited/audits/query-1ae402d409ee3a828c0f94e5cd171ef7-1-20171231160000000000"

     # ./spec/audited/audit_spec.rb:178:in `block (3 levels) in <top (required)>'
```

Without using `Time.zone.parse`, the `Time.parse` method will default to
the local timezone, which would cause an error in this specific case
(4PM UTC is 12AM SGT).
Copy link
Collaborator

@tbrisker tbrisker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jsantos !

@danielmorrison danielmorrison merged commit c5fb28a into collectiveidea:master Jan 8, 2021
@jsantos jsantos deleted the bugfix/timezone_flaky_test branch January 15, 2021 01:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants