Skip to content

Commit e562dde

Browse files
author
David Heinemeier Hansson
committed
Add failing test for preloading with a polymorphic association and using the existential predicate
1 parent 6935075 commit e562dde

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

activerecord/test/cases/associations/eager_test.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
require 'models/tag'
55
require 'models/comment'
66
require 'models/author'
7+
require 'models/essay'
78
require 'models/category'
89
require 'models/company'
910
require 'models/person'
@@ -24,7 +25,7 @@
2425
require 'models/sponsor'
2526

2627
class EagerAssociationTest < ActiveRecord::TestCase
27-
fixtures :posts, :comments, :authors, :author_addresses, :categories, :categories_posts,
28+
fixtures :posts, :comments, :authors, :essays, :author_addresses, :categories, :categories_posts,
2829
:companies, :accounts, :tags, :taggings, :people, :readers, :categorizations,
2930
:owners, :pets, :author_favorites, :jobs, :references, :subscribers, :subscriptions, :books,
3031
:developers, :projects, :developers_projects, :members, :memberships, :clubs, :sponsors
@@ -1185,4 +1186,12 @@ def test_deep_including_through_habtm
11851186
author = Author.includes(:posts).references(:posts).reorder(:name).find_by('posts.title IS NOT NULL')
11861187
assert_equal authors(:bob), author
11871188
end
1189+
1190+
test "preloading with a polymorphic association and using the existential predicate" do
1191+
assert_equal authors(:david), authors(:david).essays.includes(:writer).first.writer
1192+
1193+
assert_nothing_raised do
1194+
authors(:david).essays.includes(:writer).any?
1195+
end
1196+
end
11881197
end

0 commit comments

Comments
 (0)