aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorMikhail Dieterle <MikDiet@gmail.com>2013-08-20 14:21:23 +0300
committerMikhail Dieterle <MikDiet@gmail.com>2013-08-27 15:47:21 +0300
commitc2e084ac486a715fb04d49e4c2c33f62b07535dd (patch)
treeff922f187a50e105b419d2e5d3415a826a301ee0 /activerecord/test
parentaf3a69a783ea810d0045a6106f6c59573984f2ff (diff)
downloadrails-c2e084ac486a715fb04d49e4c2c33f62b07535dd.tar.gz
rails-c2e084ac486a715fb04d49e4c2c33f62b07535dd.tar.bz2
rails-c2e084ac486a715fb04d49e4c2c33f62b07535dd.zip
check class hierarchy with is_a? in PredicateBuilder.expand
add changelog entry for #11945
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/relation/where_test.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/activerecord/test/cases/relation/where_test.rb b/activerecord/test/cases/relation/where_test.rb
index d333be3560..3e460fa3d6 100644
--- a/activerecord/test/cases/relation/where_test.rb
+++ b/activerecord/test/cases/relation/where_test.rb
@@ -81,6 +81,31 @@ module ActiveRecord
assert_equal expected.to_sql, actual.to_sql
end
+ def test_decorated_polymorphic_where
+ treasure_decorator = Struct.new(:model) do
+ def self.method_missing(method, *args, &block)
+ Treasure.send(method, *args, &block)
+ end
+
+ def is_a?(klass)
+ model.is_a?(klass)
+ end
+
+ def method_missing(method, *args, &block)
+ model.send(method, *args, &block)
+ end
+ end
+
+ treasure = Treasure.new
+ treasure.id = 1
+ decorated_treasure = treasure_decorator.new(treasure)
+
+ expected = PriceEstimate.where(estimate_of_type: 'Treasure', estimate_of_id: 1)
+ actual = PriceEstimate.where(estimate_of: decorated_treasure)
+
+ assert_equal expected.to_sql, actual.to_sql
+ end
+
def test_aliased_attribute
expected = Topic.where(heading: 'The First Topic')
actual = Topic.where(title: 'The First Topic')