Description
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:
- 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 failureFailed 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.