public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Don't raise exception when comparing ActiveRecord::Reflection. [#842 
state:resolved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
ryanb (author)
Fri Aug 15 13:51:57 -0700 2008
lifo (committer)
Sat Aug 16 12:21:36 -0700 2008
commit  8f4d3957a6986fe450cfd9058bb92ae1d6e5e745
tree    1b7833a2d0594835f44646bc4ebc7e70a2cc219b
parent  b3c9d53b348f586ed223ec5de9f525faee6f564d
...
109
110
111
112
 
113
114
115
...
109
110
111
 
112
113
114
115
0
@@ -109,7 +109,7 @@ module ActiveRecord
0
       # Returns +true+ if +self+ and +other_aggregation+ have the same +name+ attribute, +active_record+ attribute,
0
       # and +other_aggregation+ has an options hash assigned to it.
0
       def ==(other_aggregation)
0
-        name == other_aggregation.name && other_aggregation.options && active_record == other_aggregation.active_record
0
+        other_aggregation.kind_of?(self.class) && name == other_aggregation.name && other_aggregation.options && active_record == other_aggregation.active_record
0
       end
0
 
0
       def sanitized_conditions #:nodoc:
...
166
167
168
 
 
 
 
169
170
171
...
166
167
168
169
170
171
172
173
174
175
0
@@ -166,6 +166,10 @@ class ReflectionTest < ActiveRecord::TestCase
0
     assert_equal 0, Firm.reflect_on_all_associations(:belongs_to).size
0
   end
0
 
0
+  def test_reflection_should_not_raise_error_when_compared_to_other_object
0
+    assert_nothing_raised { Firm.reflections[:clients] == Object.new }
0
+  end
0
+
0
   private
0
     def assert_reflection(klass, association, options)
0
       assert reflection = klass.reflect_on_association(association)

Comments