aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations_test.rb
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2017-05-30 18:17:20 +0930
committerMatthew Draper <matthew@trebex.net>2017-05-30 18:21:10 +0930
commit5d9d6a4fbf72029266bfa643929a9a80f9286fbe (patch)
treecb9db5087669187df4214c7d53a4e592af9bd592 /activerecord/test/cases/associations_test.rb
parent75226cc7d8224762932d4f5593ea366f25cbf61e (diff)
downloadrails-5d9d6a4fbf72029266bfa643929a9a80f9286fbe.tar.gz
rails-5d9d6a4fbf72029266bfa643929a9a80f9286fbe.tar.bz2
rails-5d9d6a4fbf72029266bfa643929a9a80f9286fbe.zip
Add an extra test showing why collections are cached
The assert_same above obviously guarantees this will pass, but this seems less likely to be deleted just because the implementation changed.
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 ff31c82794..2eb31326a5 100644
--- a/activerecord/test/cases/associations_test.rb
+++ b/activerecord/test/cases/associations_test.rb
@@ -225,6 +225,13 @@ class AssociationProxyTest < ActiveRecord::TestCase
assert_same david.projects, david.projects
end
+ test "proxy object can be stubbed" do
+ david = developers(:david)
+ david.projects.define_singleton_method(:extra_method) { 42 }
+
+ assert_equal 42, david.projects.extra_method
+ end
+
test "inverses get set of subsets of the association" do
man = Man.create
man.interests.create