aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test/cases')
-rwxr-xr-xactiverecord/test/cases/associations_test.rb12
-rwxr-xr-xactiverecord/test/cases/base_test.rb2
2 files changed, 13 insertions, 1 deletions
diff --git a/activerecord/test/cases/associations_test.rb b/activerecord/test/cases/associations_test.rb
index a15abf90a6..0df508d01d 100755
--- a/activerecord/test/cases/associations_test.rb
+++ b/activerecord/test/cases/associations_test.rb
@@ -1308,6 +1308,18 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase
assert_equal 0, Topic.find(debate.id).send(:read_attribute, "replies_count"), "First reply deleted"
end
+ def test_belongs_to_counter_with_assigning_nil
+ p = Post.find(1)
+ c = Comment.find(1)
+
+ assert_equal p.id, c.post_id
+ assert_equal 2, Post.find(p.id).comments.size
+
+ c.post = nil
+
+ assert_equal 1, Post.find(p.id).comments.size
+ end
+
def test_belongs_to_counter_with_reassigning
t1 = Topic.create("title" => "t1")
t2 = Topic.create("title" => "t2")
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb
index 4339b725c8..04ed751eb5 100755
--- a/activerecord/test/cases/base_test.rb
+++ b/activerecord/test/cases/base_test.rb
@@ -877,7 +877,7 @@ class BasicsTest < ActiveRecord::TestCase
end
def test_readonly_attributes
- assert_equal Set.new([ 'title' ]), ReadonlyTitlePost.readonly_attributes
+ assert_equal Set.new([ 'title', 'comments_count' ]), ReadonlyTitlePost.readonly_attributes
post = ReadonlyTitlePost.create(:title => "cannot change this", :body => "changeable")
post.reload