diff options
author | Bogdan Gusiev <agresso@gmail.com> | 2015-09-03 16:38:59 +0300 |
---|---|---|
committer | Bogdan Gusiev <agresso@gmail.com> | 2015-09-03 16:38:59 +0300 |
commit | 712fc8a570bc0709c3be5645e9808b0ad8fcfe45 (patch) | |
tree | a76e90ac21ef66f20e1de30b056e24b0b633fd46 /activerecord/test | |
parent | 0294c61359340892f0c38f57b203ba58edbc55e5 (diff) | |
download | rails-712fc8a570bc0709c3be5645e9808b0ad8fcfe45.tar.gz rails-712fc8a570bc0709c3be5645e9808b0ad8fcfe45.tar.bz2 rails-712fc8a570bc0709c3be5645e9808b0ad8fcfe45.zip |
HasManyAssociation: moved half of counter cache code to reflection
Current implementation has a lot of utility methods that accept
reflection call a lot of methods on it and exit.
E.g. has_counter_cache?(reflection)
It causes confusion and inability to cache result of the method even
through it always returns the same result for the same reflection
object.
It can be done easier without access to the association context
by moving code into reflection itself.
e.g. reflection.has_counter_cache?
Reflection is less complex object than association so moving code there
automatically makes it simplier to understand.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/associations/has_many_associations_test.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb index f487065d9d..7de5bc01ae 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -939,7 +939,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase # option is not given on the association. ship = Ship.create(name: 'Countless', treasures_count: 10) - assert_not ship.treasures.instance_variable_get('@association').send(:has_cached_counter?) + assert_not Ship.reflect_on_association(:treasures).has_cached_counter? # Count should come from sql count() of treasures rather than treasures_count attribute assert_equal ship.treasures.size, 0 |