Sha256: 09b85bc4b6c6162398bc5a09e84d4eac1301cf598e7c194b5edc061f729e6b48

Contents?: true

Size: 554 Bytes

Versions: 63

Compression:

Stored size: 554 Bytes

Contents

module TimeZoneTestHelpers
  def with_tz_default(tz = nil)
    old_tz = Time.zone
    Time.zone = tz
    yield
  ensure
    Time.zone = old_tz
  end

  def with_env_tz(new_tz = 'US/Eastern')
    old_tz, ENV['TZ'] = ENV['TZ'], new_tz
    yield
  ensure
    old_tz ? ENV['TZ'] = old_tz : ENV.delete('TZ')
  end

  def with_preserve_timezone(value)
    old_preserve_tz = ActiveSupport.to_time_preserves_timezone
    ActiveSupport.to_time_preserves_timezone = value
    yield
  ensure
    ActiveSupport.to_time_preserves_timezone = old_preserve_tz
  end
end

Version data entries

63 entries across 63 versions & 1 rubygems

Version Path
oj-3.9.2 test/activesupport5/time_zone_test_helpers.rb
oj-3.9.1 test/activesupport5/time_zone_test_helpers.rb
oj-3.9.0 test/activesupport5/time_zone_test_helpers.rb
oj-3.8.1 test/activesupport5/time_zone_test_helpers.rb
oj-3.8.0 test/activesupport5/time_zone_test_helpers.rb
oj-3.7.12 test/activesupport5/time_zone_test_helpers.rb
oj-3.7.11 test/activesupport5/time_zone_test_helpers.rb
oj-3.7.10 test/activesupport5/time_zone_test_helpers.rb
oj-3.7.9 test/activesupport5/time_zone_test_helpers.rb
oj-3.7.8 test/activesupport5/time_zone_test_helpers.rb
oj-3.7.7 test/activesupport5/time_zone_test_helpers.rb
oj-3.7.6 test/activesupport5/time_zone_test_helpers.rb
oj-3.7.5 test/activesupport5/time_zone_test_helpers.rb
oj-3.7.4 test/activesupport5/time_zone_test_helpers.rb
oj-3.7.3 test/activesupport5/time_zone_test_helpers.rb
oj-3.7.2 test/activesupport5/time_zone_test_helpers.rb
oj-3.7.1 test/activesupport5/time_zone_test_helpers.rb
oj-3.7.0 test/activesupport5/time_zone_test_helpers.rb
oj-3.6.13 test/activesupport5/time_zone_test_helpers.rb
oj-3.6.12 test/activesupport5/time_zone_test_helpers.rb