diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-09-28 23:55:50 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-09-28 23:55:50 +0000 |
commit | 26174b2881c8f71a1477a1d69353262e682cbd32 (patch) | |
tree | d834aa288b8f242cf1e7331527a9d97eeb3c611d | |
parent | 191a0484f03c02a2355208ebaba69cdec11df4ba (diff) | |
download | rails-26174b2881c8f71a1477a1d69353262e682cbd32.tar.gz rails-26174b2881c8f71a1477a1d69353262e682cbd32.tar.bz2 rails-26174b2881c8f71a1477a1d69353262e682cbd32.zip |
Failing counter cache test. References #6896.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7675 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rwxr-xr-x | activerecord/test/associations_test.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/activerecord/test/associations_test.rb b/activerecord/test/associations_test.rb index e6c7944dbb..59951d47fb 100755 --- a/activerecord/test/associations_test.rb +++ b/activerecord/test/associations_test.rb @@ -1158,6 +1158,24 @@ class BelongsToAssociationsTest < Test::Unit::TestCase assert_equal 0, Topic.find(t2.id).replies.size end + def test_belongs_to_counter_after_save + topic = Topic.create!(:title => "monday night") + topic.replies.create!(:title => "re: monday night", :content => "football") + assert_equal 1, Topic.find(topic.id)[:replies_count] + + topic.save! + assert_equal 1, Topic.find(topic.id)[:replies_count] + end + + def test_belongs_to_counter_after_update_attributes + topic = Topic.create!(:title => "37s") + topic.replies.create!(:title => "re: 37s", :content => "rails") + assert_equal 1, Topic.find(topic.id)[:replies_count] + + topic.update_attributes(:title => "37signals") + assert_equal 1, Topic.find(topic.id)[:replies_count] + end + def test_assignment_before_parent_saved client = Client.find(:first) apple = Firm.new("name" => "Apple") |