aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorBogdan Gusiev <agresso@gmail.com>2011-07-05 10:51:40 +0300
committerBogdan Gusiev <agresso@gmail.com>2011-07-05 10:51:40 +0300
commit8ba0c1ac5315c24cd7132267152b9d126c6ddf52 (patch)
tree3ee888c06afafd43968f3ff1f6f45b8236e434b8 /activerecord/test
parent9f7442a3abf1242a2348bfdd0c700f707ee04c52 (diff)
downloadrails-8ba0c1ac5315c24cd7132267152b9d126c6ddf52.tar.gz
rails-8ba0c1ac5315c24cd7132267152b9d126c6ddf52.tar.bz2
rails-8ba0c1ac5315c24cd7132267152b9d126c6ddf52.zip
Fixed CollectionAssociation#find to be compatible with Array#find
In order to make CollectionAssociation behave closer to Array Add the ability to pass block to #find method just like Array#find does.
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/associations/has_many_associations_test.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb
index 7e331658a3..a2764f3e3b 100644
--- a/activerecord/test/cases/associations/has_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_associations_test.rb
@@ -226,6 +226,10 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
assert_equal 2, Firm.find(:first, :order => "id").clients.length
end
+ def test_finding_array_compatibility
+ assert_equal 2, Firm.order(:id).find{|f| f.id > 0}.clients.length
+ end
+
def test_find_with_blank_conditions
[[], {}, nil, ""].each do |blank|
assert_equal 2, Firm.find(:first, :order => "id").clients.find(:all, :conditions => blank).size