提交 e9ba12f7 编写于 作者: R Ryuta Kamizono

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.
上级 46a366e7
......@@ -109,6 +109,15 @@ def test_polymorphic_shallow_where
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 @@ def test_polymorphic_nested_array_where
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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册