diff options
author | Gonçalo Silva <goncalossilva@gmail.com> | 2010-07-10 17:36:10 +0100 |
---|---|---|
committer | Gonçalo Silva <goncalossilva@gmail.com> | 2010-07-10 17:36:10 +0100 |
commit | cd2bbed9846d84a1230a1b9e52843eedca17b28d (patch) | |
tree | 5214b7855f3d102e4c22239b9d62bc5717cb3547 /activerecord/test/cases/counter_cache_test.rb | |
parent | d2c633ba0bfb7baacdee89a46d7d036d24c68817 (diff) | |
parent | 80e47d7b88dcc732ebeb5290faab6e529829dac6 (diff) | |
download | rails-cd2bbed9846d84a1230a1b9e52843eedca17b28d.tar.gz rails-cd2bbed9846d84a1230a1b9e52843eedca17b28d.tar.bz2 rails-cd2bbed9846d84a1230a1b9e52843eedca17b28d.zip |
Merge branch 'master' of http://github.com/rails/rails
Diffstat (limited to 'activerecord/test/cases/counter_cache_test.rb')
-rw-r--r-- | activerecord/test/cases/counter_cache_test.rb | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/activerecord/test/cases/counter_cache_test.rb b/activerecord/test/cases/counter_cache_test.rb index 377de168b9..137236255d 100644 --- a/activerecord/test/cases/counter_cache_test.rb +++ b/activerecord/test/cases/counter_cache_test.rb @@ -1,17 +1,20 @@ require 'cases/helper' require 'models/topic' +require 'models/car' +require 'models/wheel' +require 'models/engine' require 'models/reply' require 'models/category' require 'models/categorization' class CounterCacheTest < ActiveRecord::TestCase - fixtures :topics, :categories, :categorizations + fixtures :topics, :categories, :categorizations, :cars - class SpecialTopic < ::Topic + class ::SpecialTopic < ::Topic has_many :special_replies, :foreign_key => 'parent_id' end - class SpecialReply < ::Reply + class ::SpecialReply < ::Reply belongs_to :special_topic, :foreign_key => 'parent_id', :counter_cache => 'replies_count' end @@ -58,6 +61,16 @@ class CounterCacheTest < ActiveRecord::TestCase end end + test "reset counter should with belongs_to which has class_name" do + car = cars(:honda) + assert_nothing_raised do + Car.reset_counters(car.id, :engines) + end + assert_nothing_raised do + Car.reset_counters(car.id, :wheels) + end + end + test "update counter with initial null value" do category = categories(:general) assert_equal 2, category.categorizations.count |