Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix failing spec in 1.8.7 and potential problem in 1.9...

"should inherit alias scopes from superclasses" creates an anonymous subclass for its test. Anonymous classes return nil for .name by default.
It passed in 1.9 because Searchlogic::ActiveRecord::Scope#scopes's monkey patched `include?` was inadvertantly calling .respond_to?(key) on `result` instead of the AR class. In 1.8.7, it resulted in a syntax error `unexpected '.', expecting kEND` in `.respond_to?(key)` because name was nil. So, instead of looking up the AR class by name, now a reference to the class is passed in.
  • Loading branch information...
commit 3958111d3735cee4f3ffde60813fe624835cad2c 1 parent 046f0c1
@johndouthat authored
Showing with 8 additions and 1 deletion.
  1. +8 −1 lib/searchlogic/active_record/scope.rb
View
9 lib/searchlogic/active_record/scope.rb
@@ -8,14 +8,21 @@ module ActiveRecord
module Scope
def scopes
read_inheritable_attribute(:scopes) || write_inheritable_attribute(:scopes, {}.tap do |h|
+
+ class << h
+ attr_accessor :active_record_class
+ end
+ h.active_record_class = self
+
h.instance_eval <<-eval
def include?(key)
result = super
return result if result
- #{name}.respond_to?(key)
+ active_record_class.respond_to?(key)
super
end
eval
+
end)
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.