Created
October 12, 2017 15:50
-
-
Save davidbalbert/9fb2f6cd7b34bd9ba6b28d5f233cf848 to your computer and use it in GitHub Desktop.
This file contains 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
# frozen_string_literal: true | |
begin | |
require "bundler/inline" | |
rescue LoadError => e | |
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler" | |
raise e | |
end | |
gemfile(true) do | |
source "https://rubygems.org" | |
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |
# Activate the gem you are reporting the issue against. | |
gem "activesupport", "5.1.4" | |
end | |
require "active_support/all" | |
require "minitest/autorun" | |
# Ensure backward compatibility with Minitest 4 | |
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test) | |
class TimeWithZoneComparisonBug < Minitest::Test | |
def test_utc | |
Time.zone = "UTC" | |
run_comparisons | |
end | |
def test_new_york | |
Time.zone = "America/New_York" | |
run_comparisons | |
end | |
def test_berlin | |
Time.zone = "Europe/Berlin" | |
run_comparisons | |
end | |
private | |
def run_comparisons | |
date = Date.current | |
datetime = date.to_datetime | |
time_with_zone = date.in_time_zone | |
assert datetime <= date | |
assert date >= datetime | |
assert time_with_zone <= date | |
assert date >= time_with_zone | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment