aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/eager_test.rb
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2016-03-03 16:49:31 +0100
committerYves Senn <yves.senn@gmail.com>2016-03-03 16:52:35 +0100
commitcd73632d9d47752013f46e775e59241215cfd8e9 (patch)
treeabe436e4af39fc0461191b9190b7f88e36625433 /activerecord/test/cases/associations/eager_test.rb
parentba438dbfaed4d6bc62ffc519993770753eb74259 (diff)
downloadrails-cd73632d9d47752013f46e775e59241215cfd8e9.tar.gz
rails-cd73632d9d47752013f46e775e59241215cfd8e9.tar.bz2
rails-cd73632d9d47752013f46e775e59241215cfd8e9.zip
don't treat all associations with extensions as instance dependent.
Closes #23934. This is a forward port of ac832a43b4d026dbad28fed196d2de69ec9928ac Previously the scope of all associations with extensions were wrapped in an instance dependent proc. This made it impossible to preload such associations.
Diffstat (limited to 'activerecord/test/cases/associations/eager_test.rb')
-rw-r--r--activerecord/test/cases/associations/eager_test.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb
index 3ee84fb66c..7f2a2229ee 100644
--- a/activerecord/test/cases/associations/eager_test.rb
+++ b/activerecord/test/cases/associations/eager_test.rb
@@ -1392,6 +1392,18 @@ class EagerAssociationTest < ActiveRecord::TestCase
assert_equal('10 was not recognized for preload', exception.message)
end
+ test "associations with extensions are not instance dependent" do
+ assert_nothing_raised do
+ Author.includes(:posts_with_extension).to_a
+ end
+ end
+
+ test "including associations with extensions and an instance dependent scope is not supported" do
+ e = assert_raises(ArgumentError) do
+ Author.includes(:posts_with_extension_and_instance).to_a
+ end
+ assert_match(/Preloading instance dependent scopes is not supported/, e.message)
+ end
test "preloading readonly association" do
# has-one