aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorDaniel E. Garcia Shulman <vinagrito@users.noreply.github.com>2016-11-02 21:45:54 +0200
committerSean Griffin <sean@seantheprogrammer.com>2016-11-02 15:45:54 -0400
commit032ab94332fd5496c5af627bc36445cea3ba476a (patch)
treed05d12ef989a1bcee943da587227b8b0b72c8c42 /activerecord/test
parent7b0b119c500d45b9bc751e5346ad5f316dddcc29 (diff)
downloadrails-032ab94332fd5496c5af627bc36445cea3ba476a.tar.gz
rails-032ab94332fd5496c5af627bc36445cea3ba476a.tar.bz2
rails-032ab94332fd5496c5af627bc36445cea3ba476a.zip
Fixes TypeError Exception when cache counter value equals nil (#26940)
* Fixes TypeError when cache counter value equals nil * Test case for counter cache on unloaded has_many association
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/associations/has_many_associations_test.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb
index 7eb04b1ffd..3afd062950 100644
--- a/activerecord/test/cases/associations/has_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_associations_test.rb
@@ -1742,6 +1742,11 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
assert !company.clients.loaded?
end
+ def test_counter_cache_on_unloaded_association
+ car = Car.create(name: "My AppliCar")
+ assert_equal car.engines.size, 0
+ end
+
def test_get_ids_ignores_include_option
assert_equal [readers(:michael_welcome).id], posts(:welcome).readers_with_person_ids
end