@@ -611,6 +611,47 @@ def test_add_on_delete_restrict_foreign_key_coerced
611611class HasOneAssociationsTest < ActiveRecord ::TestCase
612612 # We use OFFSET/FETCH vs TOP. So we always have an order.
613613 coerce_tests! :test_has_one_does_not_use_order_by
614+
615+ # Asserted SQL to get one row different from original test.
616+ coerce_tests! :test_has_one
617+ def test_has_one_coerced
618+ firm = companies ( :first_firm )
619+ first_account = Account . find ( 1 )
620+ assert_sql ( /FETCH NEXT @1 ROWS ONLY(.)*@1 = 1/ ) do
621+ assert_equal first_account , firm . account
622+ assert_equal first_account . credit_limit , firm . account . credit_limit
623+ end
624+ end
625+ end
626+
627+
628+
629+
630+ class HasOneThroughAssociationsTest < ActiveRecord ::TestCase
631+ # Asserted SQL to get one row different from original test.
632+ coerce_tests! :test_has_one_through_executes_limited_query
633+ def test_has_one_through_executes_limited_query_coerced
634+ boring_club = clubs ( :boring_club )
635+ assert_sql ( /FETCH NEXT @3 ROWS ONLY(.)*@3 = 1/ ) do
636+ assert_equal boring_club , @member . general_club
637+ end
638+ end
639+ end
640+
641+
642+
643+
644+ class BelongsToAssociationsTest < ActiveRecord ::TestCase
645+ # Asserted SQL to get one row different from original test.
646+ coerce_tests! :test_belongs_to
647+ def test_belongs_to_coerced
648+ client = Client . find ( 3 )
649+ first_firm = companies ( :first_firm )
650+ assert_sql ( /FETCH NEXT @3 ROWS ONLY(.)*@3 = 1/ ) do
651+ assert_equal first_firm , client . firm
652+ assert_equal first_firm . name , client . firm . name
653+ end
654+ end
614655end
615656
616657
0 commit comments