From 5b28e42f65aa4dcb5dfcea76c5dcf564601a8853 Mon Sep 17 00:00:00 2001 From: Jonathan Hefner Date: Sun, 12 Apr 2020 00:24:29 -0500 Subject: [PATCH] Fix random CI fail due to non-deterministic order Example failure: https://buildkite.com/rails/rails/builds/68187#333e3624-ac0d-4b23-95b9-f068d9901093/1016-1028 These tests expect the 2nd Account fixture (with a NULL `firm_id`) to be in the first four rows of the result set, but that behavior is not guaranteed without an `order`. --- activerecord/test/cases/calculations_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb index 0e8cde5b97..3fd7669eb4 100644 --- a/activerecord/test/cases/calculations_test.rb +++ b/activerecord/test/cases/calculations_test.rb @@ -169,14 +169,14 @@ def test_should_limit_calculation_with_offset end def test_limit_should_apply_before_count - accounts = Account.limit(4) + accounts = Account.order(:id).limit(4) assert_equal 3, accounts.count(:firm_id) assert_equal 3, accounts.select(:firm_id).count end def test_limit_should_apply_before_count_arel_attribute - accounts = Account.limit(4) + accounts = Account.order(:id).limit(4) firm_id_attribute = Account.arel_table[:firm_id] assert_equal 3, accounts.count(firm_id_attribute) -- GitLab