mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
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.
This commit is contained in:
parent
46a366e7f2
commit
e9ba12f746
1 changed files with 19 additions and 0 deletions
|
@ -109,6 +109,15 @@ module ActiveRecord
|
||||||
assert_equal expected.to_sql, actual.to_sql
|
assert_equal expected.to_sql, actual.to_sql
|
||||||
end
|
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
|
def test_polymorphic_nested_array_where
|
||||||
treasure = Treasure.new
|
treasure = Treasure.new
|
||||||
treasure.id = 1
|
treasure.id = 1
|
||||||
|
@ -121,6 +130,16 @@ module ActiveRecord
|
||||||
assert_equal expected.to_sql, actual.to_sql
|
assert_equal expected.to_sql, actual.to_sql
|
||||||
end
|
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
|
def test_polymorphic_array_where_multiple_types
|
||||||
treasure_1 = treasures(:diamond)
|
treasure_1 = treasures(:diamond)
|
||||||
treasure_2 = treasures(:sapphire)
|
treasure_2 = treasures(:sapphire)
|
||||||
|
|
Loading…
Reference in a new issue