aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2010-07-14 18:32:24 +0100
committerPratik Naik <pratiknaik@gmail.com>2010-07-14 18:32:28 +0100
commitd5921cdb7a00b393d0ba5f2f795da60a33b11cf1 (patch)
tree25740721ce3f5280f6b8b6ae1e50011060a82011 /activerecord/test
parent4a06489525809755bcb8fd4c05394dbfb900f237 (diff)
downloadrails-d5921cdb7a00b393d0ba5f2f795da60a33b11cf1.tar.gz
rails-d5921cdb7a00b393d0ba5f2f795da60a33b11cf1.tar.bz2
rails-d5921cdb7a00b393d0ba5f2f795da60a33b11cf1.zip
Remove unintentional API changes. [#1108]
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/associations/has_many_associations_test.rb50
1 files changed, 9 insertions, 41 deletions
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb
index 6218cdd344..6fe737a817 100644
--- a/activerecord/test/cases/associations/has_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_associations_test.rb
@@ -47,14 +47,14 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
Client.destroyed_client_ids.clear
end
- def test_create_by
- person = Person.create! :first_name => 'tenderlove'
- post = Post.find :first
+ def test_create_resets_cached_counters
+ person = Person.create!(:first_name => 'tenderlove')
+ post = Post.first
assert_equal [], person.readers
- assert_nil person.readers.find_by_post_id post.id
+ assert_nil person.readers.find_by_post_id(post.id)
- reader = person.readers.create_by_post_id post.id
+ reader = person.readers.create(:post_id => post.id)
assert_equal 1, person.readers.count
assert_equal 1, person.readers.length
@@ -62,13 +62,14 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
assert_equal person, person.readers.first.person
end
- def test_create_by_multi
+ def test_find_or_create_by_resets_cached_counters
person = Person.create! :first_name => 'tenderlove'
- post = Post.find :first
+ post = Post.first
assert_equal [], person.readers
+ assert_nil person.readers.find_by_post_id(post.id)
- reader = person.readers.create_by_post_id_and_skimmer post.id, false
+ reader = person.readers.find_or_create_by_post_id(post.id)
assert_equal 1, person.readers.count
assert_equal 1, person.readers.length
@@ -76,39 +77,6 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
assert_equal person, person.readers.first.person
end
- def test_find_or_create_by
- person = Person.create! :first_name => 'tenderlove'
- post = Post.find :first
-
- assert_equal [], person.readers
- assert_nil person.readers.find_by_post_id post.id
-
- reader = person.readers.find_or_create_by_post_id post.id
-
- assert_equal 1, person.readers.count
- assert_equal 1, person.readers.length
- assert_equal post, person.readers.first.post
- assert_equal person, person.readers.first.person
- end
-
- def test_find_or_create
- person = Person.create! :first_name => 'tenderlove'
- post = Post.find :first
-
- assert_equal [], person.readers
- assert_nil person.readers.find(:first, :conditions => {
- :post_id => post.id
- })
-
- reader = person.readers.find_or_create :post_id => post.id
-
- assert_equal 1, person.readers.count
- assert_equal 1, person.readers.length
- assert_equal post, person.readers.first.post
- assert_equal person, person.readers.first.person
- end
-
-
def force_signal37_to_load_all_clients_of_firm
companies(:first_firm).clients_of_firm.each {|f| }
end