diff options
author | Arthur Neves <arthurnn@gmail.com> | 2013-09-25 19:06:00 -0400 |
---|---|---|
committer | Arthur Neves <arthurnn@gmail.com> | 2013-09-25 19:06:00 -0400 |
commit | 645af000a4bb0c742063e61d8da01aa5053bc9da (patch) | |
tree | f434f3b2407cd09d335b1deddd2cb846ed2ceeda /activerecord/test | |
parent | d1e36842ba8f3eb723fd65535cf292c898c73b68 (diff) | |
download | rails-645af000a4bb0c742063e61d8da01aa5053bc9da.tar.gz rails-645af000a4bb0c742063e61d8da01aa5053bc9da.tar.bz2 rails-645af000a4bb0c742063e61d8da01aa5053bc9da.zip |
fix .find when inverse is set
.find([1]) should return an Array of entries, even when a invese object is in memory already
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/associations/has_many_associations_test.rb | 12 |
1 files changed, 12 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 fd9b129ed4..064e31f634 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -337,6 +337,18 @@ class HasManyAssociationsTest < ActiveRecord::TestCase assert_raise(ActiveRecord::RecordNotFound) { firm.clients.find(2, 99) } end + def test_find_ids_and_inverse_of + force_signal37_to_load_all_clients_of_firm + + firm = companies(:first_firm) + client = firm.clients_of_firm.find(3) + assert_kind_of Client, client + + client_ary = firm.clients_of_firm.find([3]) + assert_kind_of Array, client_ary + assert_equal client, client_ary.first + end + def test_find_all firm = Firm.all.merge!(:order => "id").first assert_equal 2, firm.clients.where("#{QUOTED_TYPE} = 'Client'").to_a.length |