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

Tests expose DST bug between midnight and 1am in BST #1044

Open
denny opened this issue Apr 2, 2021 · 0 comments
Open

Tests expose DST bug between midnight and 1am in BST #1044

denny opened this issue Apr 2, 2021 · 0 comments
Labels
bug About something that is broken help wanted Can you help with this? i18n Internationalisation: translation / localisation / etc

Comments

@denny
Copy link
Owner

denny commented Apr 2, 2021

We're into daylight saving time in the UK now (BST, UTC+1), and every time I run my tests between midnight and 01:00 this one fails:

  1. ShinyLists::Admin::SubscriptionsController GET /admin/list/:id/subscriptions/search?q=2001-12-31 displays the list of matching subscriptions
    Failure/Error: expect( response.body ).to have_css 'td', text: 2.days.ago.to_s( :shinydate_with_day )
    expected to find visible css "td" with text "Wed, 31 Mar 2021" but there were no matches. Also found "Subscribed (00:27 on Thu, 01 Apr 2021)", which matched the selector but not all filters.
    ./plugins/ShinyLists/spec/requests/shiny_lists/admin/subscriptions_controller_spec.rb:57:in `block (3 levels) in <top (required)>'

Finished in 3 minutes 14.8 seconds (files took 8.07 seconds to load)
599 examples, 1 failure

Failed examples:
rspec ./plugins/ShinyLists/spec/requests/shiny_lists/admin/subscriptions_controller_spec.rb:49 # ShinyLists::Admin::SubscriptionsController GET /admin/list/:id/subscriptions/search?q=2001-12-31 displays the list of matching subscriptions

I haven't looked into it yet, but I'm assuming there's something very embarrassing in the date/time handling - maybe in that test, more likely in the code itself, quite possibly in both 😝

For a more specific guess, I would say it's likely that the database is still in UTC (as it should be!) but ActiveRecord is using BST. I may well be guilty of causing the mismatch, with bad configuration or bad code or both.

There's a card on the project board about handling timezones; getting that done is probably the best/right way to fix this, but ripping out all timezones in favour of forcing UTC everywhere would be an acceptable first step.

@denny denny added bug About something that is broken help wanted Can you help with this? i18n Internationalisation: translation / localisation / etc labels Apr 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug About something that is broken help wanted Can you help with this? i18n Internationalisation: translation / localisation / etc
Projects
None yet
Development

No branches or pull requests

1 participant