aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2017-08-18 07:08:16 +0900
committerRyuta Kamizono <kamipo@gmail.com>2017-08-18 07:08:16 +0900
commite9ba12f746b3d149bba252df84957a9c26ad170b (patch)
tree13d9a50edbdff4ed83a39dfa71070cfdb2b8f24c /activerecord
parent46a366e7f287623b61da4b998a466eb1a9587326 (diff)
downloadrails-e9ba12f746b3d149bba252df84957a9c26ad170b.tar.gz
rails-e9ba12f746b3d149bba252df84957a9c26ad170b.tar.bz2
rails-e9ba12f746b3d149bba252df84957a9c26ad170b.zip
Add test cases for `where.not` with polymorphic association
`where.not` with multiple conditions is still unexpected behavior. But `where.not` with only polymorphic association has already been fixed in 213796fb. Closes #14161. Closes #16983. Closes #17010. Closes #26207.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/test/cases/relation/where_test.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/activerecord/test/cases/relation/where_test.rb b/activerecord/test/cases/relation/where_test.rb
index 2fe2a67b1c..d95a54a2fe 100644
--- a/activerecord/test/cases/relation/where_test.rb
+++ b/activerecord/test/cases/relation/where_test.rb
@@ -109,6 +109,15 @@ module ActiveRecord
assert_equal expected.to_sql, actual.to_sql
end
+ def test_polymorphic_shallow_where_not
+ treasure = treasures(:sapphire)
+
+ expected = [price_estimates(:diamond), price_estimates(:honda)]
+ actual = PriceEstimate.where.not(estimate_of: treasure)
+
+ assert_equal expected.sort_by(&:id), actual.sort_by(&:id)
+ end
+
def test_polymorphic_nested_array_where
treasure = Treasure.new
treasure.id = 1
@@ -121,6 +130,16 @@ module ActiveRecord
assert_equal expected.to_sql, actual.to_sql
end
+ def test_polymorphic_nested_array_where_not
+ treasure = treasures(:diamond)
+ car = cars(:honda)
+
+ expected = [price_estimates(:sapphire_1), price_estimates(:sapphire_2)]
+ actual = PriceEstimate.where.not(estimate_of: [treasure, car])
+
+ assert_equal expected.sort_by(&:id), actual.sort_by(&:id)
+ end
+
def test_polymorphic_array_where_multiple_types
treasure_1 = treasures(:diamond)
treasure_2 = treasures(:sapphire)