Skip to content

Commit

Permalink
make tests pass on Ruby 2.2
Browse files Browse the repository at this point in the history
Apparently we've been using a buggy feature for the past 6 years:

  https://bugs.ruby-lang.org/issues/9593
  • Loading branch information
tenderlove committed Mar 13, 2014
1 parent daf7e25 commit 901a0cf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ def count_records
[association_scope.limit_value, count].compact.min [association_scope.limit_value, count].compact.min
end end


def has_cached_counter?(reflection = reflection) def has_cached_counter?(reflection = reflection())
owner.attribute_present?(cached_counter_attribute_name(reflection)) owner.attribute_present?(cached_counter_attribute_name(reflection))
end end


def cached_counter_attribute_name(reflection = reflection) def cached_counter_attribute_name(reflection = reflection())
options[:counter_cache] || "#{reflection.name}_count" options[:counter_cache] || "#{reflection.name}_count"
end end


def update_counter(difference, reflection = reflection) def update_counter(difference, reflection = reflection())
if has_cached_counter?(reflection) if has_cached_counter?(reflection)
counter = cached_counter_attribute_name(reflection) counter = cached_counter_attribute_name(reflection)
owner.class.update_counters(owner.id, counter => difference) owner.class.update_counters(owner.id, counter => difference)
Expand All @@ -98,7 +98,7 @@ def update_counter(difference, reflection = reflection)
# it will be decremented twice. # it will be decremented twice.
# #
# Hence this method. # Hence this method.
def inverse_updates_counter_cache?(reflection = reflection) def inverse_updates_counter_cache?(reflection = reflection())
counter_name = cached_counter_attribute_name(reflection) counter_name = cached_counter_attribute_name(reflection)
reflection.klass.reflect_on_all_associations(:belongs_to).any? { |inverse_reflection| reflection.klass.reflect_on_all_associations(:belongs_to).any? { |inverse_reflection|
inverse_reflection.counter_cache_column == counter_name inverse_reflection.counter_cache_column == counter_name
Expand Down
2 changes: 1 addition & 1 deletion activesupport/lib/active_support/values/time_zone.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def at(secs)
# #
# Time.zone.now # => Fri, 31 Dec 1999 14:00:00 HST -10:00 # 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 # 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) parts = Date._parse(str, false)
return if parts.empty? return if parts.empty?


Expand Down

0 comments on commit 901a0cf

Please sign in to comment.