Permalink
Browse files

make tests pass on Ruby 2.2

Apparently we've been using a buggy feature for the past 6 years:

  https://bugs.ruby-lang.org/issues/9593
  • Loading branch information...
1 parent 15720df commit e88da370f190cabd1e9750c5b3531735950ab415 @tenderlove tenderlove committed Mar 13, 2014
@@ -71,15 +71,15 @@ def count_records
[association_scope.limit_value, count].compact.min
end
- def has_cached_counter?(reflection = reflection)
+ def has_cached_counter?(reflection = reflection())
owner.attribute_present?(cached_counter_attribute_name(reflection))
end
- def cached_counter_attribute_name(reflection = reflection)
+ def cached_counter_attribute_name(reflection = reflection())
options[:counter_cache] || "#{reflection.name}_count"
end
- def update_counter(difference, reflection = reflection)
+ def update_counter(difference, reflection = reflection())
if has_cached_counter?(reflection)
counter = cached_counter_attribute_name(reflection)
owner.class.update_counters(owner.id, counter => difference)
@@ -98,7 +98,7 @@ def update_counter(difference, reflection = reflection)
# it will be decremented twice.
#
# Hence this method.
- def inverse_updates_counter_cache?(reflection = reflection)
+ def inverse_updates_counter_cache?(reflection = reflection())
counter_name = cached_counter_attribute_name(reflection)
reflection.klass.reflect_on_all_associations(:belongs_to).any? { |inverse_reflection|
inverse_reflection.counter_cache_column == counter_name
@@ -282,7 +282,7 @@ def at(secs)
#
# 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=now())
parts = Date._parse(str, false)
return if parts.empty?

4 comments on commit e88da37

Can we have this in 3.2.x ? Monkeyoverriding Timezone.parse() to work for now. (Ruby v2.2.0)

undefined method `year' for nil:NilClass
activesupport-3.2.21/lib/active_support/values/time_zone.rb:275:in `parse'
Owner

rafaelfranca replied Jan 13, 2015

It is already in the 3-2-stable branch but since that branch does not have a normal release it will be released only with a security release

@rafaelfranca thank you, fellow compatriot ;)
It was just that and add 'test-unit' to Gemfile and I got a 3.2.x app running again on 2.2.0.

Owner

rafaelfranca replied Jan 13, 2015

Cool! Thank you for testing it.

Please sign in to comment.