Skip to content

Commit 25baf89

Browse files
committed
[Rails5] Coerce LENGTH function-based test to LEN.
1 parent c3ead9f commit 25baf89

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/cases/coerced_tests.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,22 @@ def test_cache_does_not_wrap_string_results_in_arrays_coerced
521521

522522
require 'models/post'
523523
class RelationTest < ActiveRecord::TestCase
524+
# Use LEN vs LENGTH function.
525+
coerce_tests! :test_reverse_order_with_function
526+
def test_reverse_order_with_function_coerced
527+
topics = Topic.order("LEN(title)").reverse_order
528+
assert_equal topics(:second).title, topics.first.title
529+
end
530+
531+
# Use LEN vs LENGTH function.
532+
coerce_tests! :test_reverse_order_with_function_other_predicates
533+
def test_reverse_order_with_function_other_predicates_coerced
534+
topics = Topic.order("author_name, LEN(title), id").reverse_order
535+
assert_equal topics(:second).title, topics.first.title
536+
topics = Topic.order("LEN(author_name), id, LEN(title)").reverse_order
537+
assert_equal topics(:fifth).title, topics.first.title
538+
end
539+
524540
# We have implicit ordering, via FETCH.
525541
coerce_tests! %r{doesn't have implicit ordering}
526542

0 commit comments

Comments
 (0)