diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2016-07-25 00:00:38 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2016-07-25 00:00:38 +0900 |
commit | ceee776b5ddf3db849bdf170be15de5a86eb28d5 (patch) | |
tree | ee967e7905c6dee99772162b0b1649facb1fbf08 | |
parent | 56527bb737eb5e1d5531cafe99ce91d025565ead (diff) | |
download | rails-ceee776b5ddf3db849bdf170be15de5a86eb28d5.tar.gz rails-ceee776b5ddf3db849bdf170be15de5a86eb28d5.tar.bz2 rails-ceee776b5ddf3db849bdf170be15de5a86eb28d5.zip |
Fix to `CollectionProxy#load` does `load_target`
-rw-r--r-- | activerecord/lib/active_record/associations/collection_proxy.rb | 6 | ||||
-rw-r--r-- | activerecord/test/cases/associations_test.rb | 8 |
2 files changed, 14 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index db3037d8f9..98250a7ab8 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -1070,6 +1070,12 @@ module ActiveRecord proxy_association.reset_scope self end + + private + + def exec_queries + load_target + end end end end diff --git a/activerecord/test/cases/associations_test.rb b/activerecord/test/cases/associations_test.rb index 01a058918a..8f570985ff 100644 --- a/activerecord/test/cases/associations_test.rb +++ b/activerecord/test/cases/associations_test.rb @@ -183,6 +183,14 @@ class AssociationProxyTest < ActiveRecord::TestCase assert !david.projects.loaded? end + def test_load_does_load_target + david = developers(:david) + + assert !david.projects.loaded? + david.projects.load + assert david.projects.loaded? + end + def test_inspect_does_not_reload_a_not_yet_loaded_target andreas = Developer.new :name => 'Andreas', :log => 'new developer added' assert !andreas.audit_logs.loaded? |