aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2019-03-11 03:48:53 +0900
committerRyuta Kamizono <kamipo@gmail.com>2019-03-11 03:56:50 +0900
commit50e01ec01a7658ba4542bb5f9b68223e98ce6180 (patch)
treef218e102ee896d0ddba425dd13ae0386b737b7a7 /activerecord
parent260a3c65122a726eea20828d4909e15502751c39 (diff)
downloadrails-50e01ec01a7658ba4542bb5f9b68223e98ce6180.tar.gz
rails-50e01ec01a7658ba4542bb5f9b68223e98ce6180.tar.bz2
rails-50e01ec01a7658ba4542bb5f9b68223e98ce6180.zip
Fix random CI failure due to non-deterministic sorting order
An `author` has a lots of `posts` in the fixtures, so the result of `author.post` and finding a `post` by `author_id` is non-deterministic. https://travis-ci.org/rails/rails/jobs/504332292#L1202-L1208
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/test/cases/finder_test.rb11
1 files changed, 6 insertions, 5 deletions
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb
index f9792bf8d3..ca114d468e 100644
--- a/activerecord/test/cases/finder_test.rb
+++ b/activerecord/test/cases/finder_test.rb
@@ -3,6 +3,7 @@
require "cases/helper"
require "models/post"
require "models/author"
+require "models/account"
require "models/categorization"
require "models/comment"
require "models/company"
@@ -461,14 +462,14 @@ class FinderTest < ActiveRecord::TestCase
end
def test_find_by_association_subquery
- author = authors(:david)
- assert_equal author.post, Post.find_by(author: Author.where(id: author))
- assert_equal author.post, Post.find_by(author_id: Author.where(id: author))
+ firm = companies(:first_firm)
+ assert_equal firm.account, Account.find_by(firm: Firm.where(id: firm))
+ assert_equal firm.account, Account.find_by(firm_id: Firm.where(id: firm))
end
def test_find_by_and_where_consistency_with_active_record_instance
- author = authors(:david)
- assert_equal Post.where(author_id: author).take, Post.find_by(author_id: author)
+ firm = companies(:first_firm)
+ assert_equal Account.where(firm_id: firm).take, Account.find_by(firm_id: firm)
end
def test_take