Skip to content

Commit e99b8d1

Browse files
authored
Merge pull request #996 from aidanharan/relation-test-sort-results
[Rails 7] Fix randomly failing Rails relations test
2 parents 633b903 + c616963 commit e99b8d1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

test/cases/coerced_tests.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,6 +1350,15 @@ def test_does_not_duplicate_optimizer_hints_on_merge_coerced
13501350
query = Post.optimizer_hints("OMGHINT").merge(Post.optimizer_hints("OMGHINT")).to_sql
13511351
assert_equal expected, query
13521352
end
1353+
1354+
# Workaround for randomly failing test. Ordering of results not guaranteed.
1355+
# TODO: Remove coerced test when https://github.com/rails/rails/pull/44168 merged.
1356+
coerce_tests! :test_select_quotes_when_using_from_clause
1357+
def test_select_quotes_when_using_from_clause_coerced
1358+
quoted_join = ActiveRecord::Base.connection.quote_table_name("join")
1359+
selected = Post.select(:join).from(Post.select("id as #{quoted_join}")).map(&:join)
1360+
assert_equal Post.pluck(:id).sort, selected.sort
1361+
end
13531362
end
13541363
end
13551364

0 commit comments

Comments
 (0)