module InTimeZone

Private Instance Methods

in_time_zone(zone) { || ... } click to toggle source
# File activerecord/test/cases/helper.rb, line 174
def in_time_zone(zone)
  old_zone  = Time.zone
  old_tz    = ActiveRecord::Base.time_zone_aware_attributes

  Time.zone = zone ? ActiveSupport::TimeZone[zone] : nil
  ActiveRecord::Base.time_zone_aware_attributes = !zone.nil?
  yield
ensure
  Time.zone = old_zone
  ActiveRecord::Base.time_zone_aware_attributes = old_tz
end