aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2013-10-28 21:26:03 -0700
committerDavid Heinemeier Hansson <david@loudthinking.com>2013-10-28 21:26:03 -0700
commite562ddedbae5d44cc98ada8a597fd84e80aea96d (patch)
tree6248e6e62aff316d90303a17d8e9115eeb6ece83 /activerecord/test/cases
parent6935075c8fe844dbc59ede9bde27e53412210db0 (diff)
downloadrails-e562ddedbae5d44cc98ada8a597fd84e80aea96d.tar.gz
rails-e562ddedbae5d44cc98ada8a597fd84e80aea96d.tar.bz2
rails-e562ddedbae5d44cc98ada8a597fd84e80aea96d.zip
Add failing test for preloading with a polymorphic association and using the existential predicate
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/associations/eager_test.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb
index 874ae77ff7..05e50cdee2 100644
--- a/activerecord/test/cases/associations/eager_test.rb
+++ b/activerecord/test/cases/associations/eager_test.rb
@@ -4,6 +4,7 @@ require 'models/tagging'
require 'models/tag'
require 'models/comment'
require 'models/author'
+require 'models/essay'
require 'models/category'
require 'models/company'
require 'models/person'
@@ -24,7 +25,7 @@ require 'models/categorization'
require 'models/sponsor'
class EagerAssociationTest < ActiveRecord::TestCase
- fixtures :posts, :comments, :authors, :author_addresses, :categories, :categories_posts,
+ fixtures :posts, :comments, :authors, :essays, :author_addresses, :categories, :categories_posts,
:companies, :accounts, :tags, :taggings, :people, :readers, :categorizations,
:owners, :pets, :author_favorites, :jobs, :references, :subscribers, :subscriptions, :books,
:developers, :projects, :developers_projects, :members, :memberships, :clubs, :sponsors
@@ -1185,4 +1186,12 @@ class EagerAssociationTest < ActiveRecord::TestCase
author = Author.includes(:posts).references(:posts).reorder(:name).find_by('posts.title IS NOT NULL')
assert_equal authors(:bob), author
end
+
+ test "preloading with a polymorphic association and using the existential predicate" do
+ assert_equal authors(:david), authors(:david).essays.includes(:writer).first.writer
+
+ assert_nothing_raised do
+ authors(:david).essays.includes(:writer).any?
+ end
+ end
end