aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorJames Dabbs <jamesdabbs@gmail.com>2015-06-13 18:36:06 -0400
committerJames Dabbs <jamesdabbs@gmail.com>2015-06-13 18:36:06 -0400
commit5a9590c6cbbb4ac26a81ae37088a38778cb12748 (patch)
tree4e8bffd5cf712f324a1bc1d710389d07c7e2056b /activerecord/test
parent3692ca5ce7a0dbb11c4001891488905c53fbc5e5 (diff)
downloadrails-5a9590c6cbbb4ac26a81ae37088a38778cb12748.tar.gz
rails-5a9590c6cbbb4ac26a81ae37088a38778cb12748.tar.bz2
rails-5a9590c6cbbb4ac26a81ae37088a38778cb12748.zip
Fix `undefined method uncached` for polymorphic belongs_to #20426
Unitialized polymorphic `belongs_to` associations raise an error while attempting to reload, as they attempt to make an uncached reload, but don't have a klass to fetch uncachedly. In this case, `loaded?` should be `false` anyway.
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/associations/belongs_to_associations_test.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/belongs_to_associations_test.rb b/activerecord/test/cases/associations/belongs_to_associations_test.rb
index ba90c61d65..f5d2fe151b 100644
--- a/activerecord/test/cases/associations/belongs_to_associations_test.rb
+++ b/activerecord/test/cases/associations/belongs_to_associations_test.rb
@@ -288,6 +288,7 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase
def test_polymorphic_association_class
sponsor = Sponsor.new
assert_nil sponsor.association(:sponsorable).send(:klass)
+ assert_nil sponsor.sponsorable(force_reload: true)
sponsor.sponsorable_type = '' # the column doesn't have to be declared NOT NULL
assert_nil sponsor.association(:sponsorable).send(:klass)