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
# spec/support/timezone.rb | |
module TimeZoneHelpers | |
extend ActiveSupport::Concern | |
def self.randomise_timezone! | |
offsets = ActiveSupport::TimeZone.all.group_by(&:formatted_offset) | |
zones = offsets[offsets.keys.sample] # Random offset to better vary the time zone differences | |
Time.zone = zones.sample # Random zone from the offset (can be just 1st, but let's do random) | |
puts "Current rand time zone: #{Time.zone}. Repro: Time.zone = #{Time.zone.name.inspect}" | |
end |