aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/associations_test.rb
diff options
context:
space:
mode:
authorJamis Buck <jamis@37signals.com>2005-06-13 12:03:33 +0000
committerJamis Buck <jamis@37signals.com>2005-06-13 12:03:33 +0000
commit37a370d8d4e3e1a5bf707ffac9cd188c07572248 (patch)
treef97803d54bb21c0f55e2b0c22d53c5c57308b858 /activerecord/test/associations_test.rb
parente0537acaeb6c432db844ff835120de7aabb1e39b (diff)
downloadrails-37a370d8d4e3e1a5bf707ffac9cd188c07572248.tar.gz
rails-37a370d8d4e3e1a5bf707ffac9cd188c07572248.tar.bz2
rails-37a370d8d4e3e1a5bf707ffac9cd188c07572248.zip
Be sure to use the @finder_sql in the has_many association's #find method, even if explicit conditions have not been given.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1412 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/associations_test.rb')
-rwxr-xr-xactiverecord/test/associations_test.rb18
1 files changed, 12 insertions, 6 deletions
diff --git a/activerecord/test/associations_test.rb b/activerecord/test/associations_test.rb
index 1e80ec1ee0..043fe9e2fb 100755
--- a/activerecord/test/associations_test.rb
+++ b/activerecord/test/associations_test.rb
@@ -540,9 +540,10 @@ class HasManyAssociationsTest < Test::Unit::TestCase
end
def test_dependence
- assert_equal 2, Client.find_all.size
- Firm.find_first.destroy
- assert Client.find_all.empty?
+ firm = companies(:first_firm)
+ assert_equal 2, firm.clients.size
+ firm.destroy
+ assert Client.find(:all, :conditions => "firm_id=#{firm.id}").empty?
end
def test_destroy_dependent_when_deleted_from_association
@@ -567,14 +568,14 @@ class HasManyAssociationsTest < Test::Unit::TestCase
uses_transaction :test_dependence_with_transaction_support_on_failure
def test_dependence_with_transaction_support_on_failure
- assert_equal 2, Client.find_all.length
- firm = Firm.find_first
+ firm = companies(:first_firm)
clients = firm.clients
+ assert_equal 2, clients.length
clients.last.instance_eval { def before_destroy() raise "Trigger rollback" end }
firm.destroy rescue "do nothing"
- assert_equal 2, Client.find_all.length
+ assert_equal 2, Client.find(:all, :conditions => "firm_id=#{firm.id}").size
end
def test_dependence_on_account
@@ -590,6 +591,11 @@ class HasManyAssociationsTest < Test::Unit::TestCase
def test_adding_array_and_collection
assert_nothing_raised { Firm.find_first.clients + Firm.find_all.last.clients }
end
+
+ def test_find_all_without_conditions
+ firm = companies(:first_firm)
+ assert_equal 2, firm.clients.find(:all).length
+ end
end
class BelongsToAssociationsTest < Test::Unit::TestCase