diff options
author | aditya-kapoor <aditya.kapoor@vinsol.com> | 2013-09-01 18:05:04 +0530 |
---|---|---|
committer | aditya-kapoor <aditya.kapoor@vinsol.com> | 2013-09-01 18:05:04 +0530 |
commit | 6b9b0767bf480d53029afeb3f8e86f66e933fb41 (patch) | |
tree | 62a76c76b8fce484d8a258aceb14ac475f2c94a8 /activerecord/test/cases/relation/where_test.rb | |
parent | b27c40637aaf2549f91faec8e87f6d4afa9a7380 (diff) | |
parent | ab0cbff07ebb5df8c9354fa2b3fd9984e039d2c6 (diff) | |
download | rails-6b9b0767bf480d53029afeb3f8e86f66e933fb41.tar.gz rails-6b9b0767bf480d53029afeb3f8e86f66e933fb41.tar.bz2 rails-6b9b0767bf480d53029afeb3f8e86f66e933fb41.zip |
Merge branch 'master' of github.com:lifo/docrails
Diffstat (limited to 'activerecord/test/cases/relation/where_test.rb')
-rw-r--r-- | activerecord/test/cases/relation/where_test.rb | 25 |
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') |