From 5d9d6a4fbf72029266bfa643929a9a80f9286fbe Mon Sep 17 00:00:00 2001 From: Matthew Draper Date: Tue, 30 May 2017 18:17:20 +0930 Subject: 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. --- activerecord/test/cases/associations_test.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'activerecord/test/cases') 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 -- cgit v1.2.3