diff options
author | Adam Rice <arice@Adams-MacBook-Pro-8.local> | 2017-02-22 14:16:59 +1100 |
---|---|---|
committer | Adam Rice <arice@Adams-MacBook-Pro-8.local> | 2017-02-22 14:16:59 +1100 |
commit | 6560448b460f16db196efe42d5fc3d51b27ea651 (patch) | |
tree | 2da14918fe2b3caf3e3fabf164a20d8e0de77467 | |
parent | 8de68078f4b55ed574d795cece38c2943642b95e (diff) | |
download | rails-6560448b460f16db196efe42d5fc3d51b27ea651.tar.gz rails-6560448b460f16db196efe42d5fc3d51b27ea651.tar.bz2 rails-6560448b460f16db196efe42d5fc3d51b27ea651.zip |
Preload to_datetime before freezing a TimeWithZone instance
-rw-r--r-- | activesupport/lib/active_support/time_with_zone.rb | 3 | ||||
-rw-r--r-- | activesupport/test/core_ext/time_with_zone_test.rb | 1 |
2 files changed, 3 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb index 889f71c4f3..857cc1a664 100644 --- a/activesupport/lib/active_support/time_with_zone.rb +++ b/activesupport/lib/active_support/time_with_zone.rb @@ -427,7 +427,8 @@ module ActiveSupport end def freeze - period; utc; time # preload instance variables before freezing + # preload instance variables before freezing + period; utc; time; to_datetime super end diff --git a/activesupport/test/core_ext/time_with_zone_test.rb b/activesupport/test/core_ext/time_with_zone_test.rb index ab5ec98642..1534daacb9 100644 --- a/activesupport/test/core_ext/time_with_zone_test.rb +++ b/activesupport/test/core_ext/time_with_zone_test.rb @@ -507,6 +507,7 @@ class TimeWithZoneTest < ActiveSupport::TestCase assert_nothing_raised do @twz.period @twz.time + @twz.to_datetime end end |