At 10 a.m. an object becomes active and visible to the user.
seconds_since_midnight.to_i at 10:00 is 36000, but that is not timezone aware.
application_controller sets a tenant and its timezone, based on one of its attributes
before_action :set_host_shop_timezone
def set_host_shop_timezone
[...]
@shop = Shop.find(@site.shop_id)
Time.zone = @shop.timezone
end
The local (server) is set at GMT +1, while application.rb does not specify any # config.time_zone = 'UTC'
Assertions are needed for:
travel_to Time.zone.local(2025, 8, 8, 9, 59, 58)
travel_to Time.zone.local(2025, 8, 8, 10, 01, 59)
Console confirms:
Time.zone.local(2025, 8, 8, 9, 59, 58).seconds_since_midnight.to_i
=> 35998
Time.zone.local(2025, 8, 8, 10, 01, 59).seconds_since_midnight.to_i
=> 36119
The tests
test 'time before trip-wire ' do
@shop = shops(:one)
travel_to Time.zone.local(2025, 8, 8, 9, 59, 58)
get root_path, headers: { "host": 'www.one.com' }
puts Time.zone
puts Time.zone.local(2025, 8, 8, 9, 59, 58).seconds_since_midnight.to_i
end
test 'time after trip-wire ' do
@shop = shops(:one)
travel_to Time.zone.local(2025, 8, 8, 10, 00, 12)
get root_path, headers: { "host": 'www.one.com' }
puts Time.zone
puts Time.zone.local(2025, 8, 8, 10, 00, 12).seconds_since_midnight.to_i
end
return expected results for timezone and seconds since midnight
(GMT+01:00) CET
35998
[...]
(GMT+01:00) CET
36659
but the response.body is wrong in the test (but not in the browser view).
The root_path action intercepts
puts Time.now
puts Time.now.seconds_since_midnight.to_i
and returns for each test:
2025-08-08 11:59:58 +0200
43198
[...]
2025-08-08 12:00:12 +0200
43212
with the offset being 2 hours (GMT + summer time).
Where is this test mistaken?