Skip to content

Commit 61cea36

Browse files
committed
[Rails51] Coerce a few tests.
* RelationTest#test_reverse_arel_assoc_order_with_function * RelationTest#test_0020_relations * RelationTest#test_empty_complex_chained_relations IMPORTANT: rails/rails#28699
1 parent 8b57687 commit 61cea36

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/cases/coerced_tests.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,26 @@ def test_reverse_order_with_function_other_predicates_coerced
613613
# Leave it up to users to format selects/functions so HAVING works correctly.
614614
coerce_tests! :test_multiple_where_and_having_clauses
615615
coerce_tests! :test_having_with_binds_for_both_where_and_having
616+
617+
# Find any limit via our expression.
618+
coerce_tests! %r{relations don't load all records in #inspect}
619+
def test_relations_dont_load_all_records_in_inspect_coerced
620+
assert_sql(/NEXT @0 ROWS.*@0 = \d+/) do
621+
Post.all.inspect
622+
end
623+
end
624+
625+
# I wanted to add `.order("author_id")` scope to avoid error: Column "posts.id" is invalid in the ORDER BY
626+
# However, this pull request on Rails core drops order on exists relation. https://github.com/rails/rails/pull/28699
627+
# so we are skipping all together.
628+
coerce_tests! :test_empty_complex_chained_relations
629+
630+
# Use LEN() vs length() function.
631+
coerce_tests! :test_reverse_arel_assoc_order_with_function
632+
def test_reverse_arel_assoc_order_with_function_coerced
633+
topics = Topic.order(Arel.sql("LEN(title)") => :asc).reverse_order
634+
assert_equal topics(:second).title, topics.first.title
635+
end
616636
end
617637

618638

0 commit comments

Comments
 (0)