diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-01-07 00:40:26 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-01-07 00:40:26 -0300 |
commit | 292f6c99229f34ab216ddc9103e219143e637d85 (patch) | |
tree | 24b4d8e07b9735aff8daf1e36029473ed880ce3a /activesupport | |
parent | ba886f73a2b4a06f3400f0698290c54566639b6a (diff) | |
parent | bcbce4e9ffc2f5a2f86d3a977a0e07e2b2aab19e (diff) | |
download | rails-292f6c99229f34ab216ddc9103e219143e637d85.tar.gz rails-292f6c99229f34ab216ddc9103e219143e637d85.tar.bz2 rails-292f6c99229f34ab216ddc9103e219143e637d85.zip |
Merge pull request #18306 from tmm1/rm-3-2-with-ruby-2-1-plus
3-2-stable: ruby 2.2 compatibility
Diffstat (limited to 'activesupport')
5 files changed, 17 insertions, 6 deletions
diff --git a/activesupport/activesupport.gemspec b/activesupport/activesupport.gemspec index e131ca7d68..f3c22871e5 100644 --- a/activesupport/activesupport.gemspec +++ b/activesupport/activesupport.gemspec @@ -22,4 +22,5 @@ Gem::Specification.new do |s| s.add_dependency('i18n', '~> 0.6', '>= 0.6.4') s.add_dependency('multi_json', '~> 1.0') + s.add_dependency('test-unit', '~> 3.0') end diff --git a/activesupport/lib/active_support/core_ext/big_decimal/conversions.rb b/activesupport/lib/active_support/core_ext/big_decimal/conversions.rb index 391bdc925d..d2039fcc1e 100644 --- a/activesupport/lib/active_support/core_ext/big_decimal/conversions.rb +++ b/activesupport/lib/active_support/core_ext/big_decimal/conversions.rb @@ -16,7 +16,9 @@ class BigDecimal # # Note that reconstituting YAML floats to native floats may lose precision. def to_yaml(opts = {}) - return super if defined?(YAML::ENGINE) && !YAML::ENGINE.syck? + return super if + (defined?(YAML::ENGINE) && !YAML::ENGINE.syck?) || + (defined?(Psych) && YAML == Psych) YAML.quick_emit(nil, opts) do |out| string = to_s diff --git a/activesupport/lib/active_support/core_ext/class/attribute.rb b/activesupport/lib/active_support/core_ext/class/attribute.rb index cd7877fce4..14adc426d8 100644 --- a/activesupport/lib/active_support/core_ext/class/attribute.rb +++ b/activesupport/lib/active_support/core_ext/class/attribute.rb @@ -109,7 +109,9 @@ class Class end private - def singleton_class? - ancestors.first != self - end + unless respond_to?(:singleton_class?) + def singleton_class? + ancestors.first != self + end + end end diff --git a/activesupport/lib/active_support/core_ext/date_time/calculations.rb b/activesupport/lib/active_support/core_ext/date_time/calculations.rb index 0481bd2195..0ff36eeb6d 100644 --- a/activesupport/lib/active_support/core_ext/date_time/calculations.rb +++ b/activesupport/lib/active_support/core_ext/date_time/calculations.rb @@ -138,6 +138,12 @@ class DateTime # Layers additional behavior on DateTime#<=> so that Time and ActiveSupport::TimeWithZone instances can be compared with a DateTime def <=>(other) - super other.kind_of?(Infinity) ? other : other.to_datetime + if other.kind_of?(Infinity) + super + elsif other.respond_to? :to_datetime + super other.to_datetime + else + nil + end end end diff --git a/activesupport/lib/active_support/values/time_zone.rb b/activesupport/lib/active_support/values/time_zone.rb index f935180036..01aea0984b 100644 --- a/activesupport/lib/active_support/values/time_zone.rb +++ b/activesupport/lib/active_support/values/time_zone.rb @@ -267,7 +267,7 @@ module ActiveSupport # # Time.zone.now # => Fri, 31 Dec 1999 14:00:00 HST -10:00 # Time.zone.parse('22:30:00') # => Fri, 31 Dec 1999 22:30:00 HST -10:00 - def parse(str, now=now) + def parse(str, now=self.now) parts = Date._parse(str, false) return if parts.empty? |