aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/associations_test.rb
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2007-09-30 07:09:44 +0000
committerRick Olson <technoweenie@gmail.com>2007-09-30 07:09:44 +0000
commit66d05f5e2c7ac6b18220956fbcf34efcd32638fc (patch)
tree6544dd694d02af7438489a4864daec9c2bdce0b5 /activerecord/test/associations_test.rb
parent30a652ad41428b922b1ed637f491776f1f1dff13 (diff)
downloadrails-66d05f5e2c7ac6b18220956fbcf34efcd32638fc.tar.gz
rails-66d05f5e2c7ac6b18220956fbcf34efcd32638fc.tar.bz2
rails-66d05f5e2c7ac6b18220956fbcf34efcd32638fc.zip
Add attr_readonly to specify columns that are skipped during a normal ActiveRecord #save operation. Closes #6896 [dcmanges]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7693 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/associations_test.rb')
-rwxr-xr-xactiverecord/test/associations_test.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/activerecord/test/associations_test.rb b/activerecord/test/associations_test.rb
index 59951d47fb..85df401fb1 100755
--- a/activerecord/test/associations_test.rb
+++ b/activerecord/test/associations_test.rb
@@ -1175,6 +1175,24 @@ class BelongsToAssociationsTest < Test::Unit::TestCase
topic.update_attributes(:title => "37signals")
assert_equal 1, Topic.find(topic.id)[:replies_count]
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).send(:read_attribute, "replies_count")
+
+ topic.save
+ assert_equal 1, Topic.find(topic.id).send(:read_attribute, "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).send(:read_attribute, "replies_count")
+
+ topic.update_attributes("title" => "37signals")
+ assert_equal 1, Topic.find(topic.id).send(:read_attribute, "replies_count")
+ end
def test_assignment_before_parent_saved
client = Client.find(:first)