From 5f66f7a9a2e497fdb8f8cbbfb423d9b3b199fd54 Mon Sep 17 00:00:00 2001 From: ganesh Date: Sat, 4 Jun 2011 00:04:59 +0530 Subject: added more tests for update_column --- .../test/cases/associations/belongs_to_associations_test.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/activerecord/test/cases/associations/belongs_to_associations_test.rb b/activerecord/test/cases/associations/belongs_to_associations_test.rb index 5a900e0605..7338513b41 100644 --- a/activerecord/test/cases/associations/belongs_to_associations_test.rb +++ b/activerecord/test/cases/associations/belongs_to_associations_test.rb @@ -296,6 +296,15 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase assert_equal 1, Topic.find(topic.id)[:replies_count] end + def test_belongs_to_counter_when_update_column + topic = Topic.create!(:title => "37s") + topic.replies.create!(:title => "re: 37s", :content => "rails") + assert_equal 1, Topic.find(topic.id)[:replies_count] + + topic.update_column(:content, "rails is wonderfull") + assert_equal 1, Topic.find(topic.id)[:replies_count] + end + def test_assignment_before_child_saved final_cut = Client.new("name" => "Final Cut") firm = Firm.find(1) -- cgit v1.2.3