aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations_test.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2016-07-28 23:31:09 +0900
committerRyuta Kamizono <kamipo@gmail.com>2016-08-04 09:13:13 +0900
commit3a8a9979acab6a6f4c6d759521c052fe2ac46d2b (patch)
tree1ab380c8ca111682cb6dc12687fc1985ee53b93e /activerecord/test/cases/associations_test.rb
parent5b469da6ec482414c5f59762ae8e82de7e07c365 (diff)
downloadrails-3a8a9979acab6a6f4c6d759521c052fe2ac46d2b.tar.gz
rails-3a8a9979acab6a6f4c6d759521c052fe2ac46d2b.tar.bz2
rails-3a8a9979acab6a6f4c6d759521c052fe2ac46d2b.zip
`pluck` should use `records` (`load_target`) when `loaded?` is true
Diffstat (limited to 'activerecord/test/cases/associations_test.rb')
-rw-r--r--activerecord/test/cases/associations_test.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations_test.rb b/activerecord/test/cases/associations_test.rb
index 7efacb44f3..671cde3a68 100644
--- a/activerecord/test/cases/associations_test.rb
+++ b/activerecord/test/cases/associations_test.rb
@@ -258,6 +258,13 @@ class AssociationProxyTest < ActiveRecord::TestCase
assert_no_queries { david.posts.first! }
end
+ def test_pluck_uses_loaded_target
+ david = authors(:david)
+ assert_equal david.posts.pluck(:title), david.posts.load.pluck(:title)
+ assert david.posts.loaded?
+ assert_no_queries { david.posts.pluck(:title) }
+ end
+
def test_reset_unloads_target
david = authors(:david)
david.posts.reload