aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorArthur Neves <arthurnn@gmail.com>2013-09-25 19:06:00 -0400
committerArthur Neves <arthurnn@gmail.com>2013-09-25 19:06:00 -0400
commit645af000a4bb0c742063e61d8da01aa5053bc9da (patch)
treef434f3b2407cd09d335b1deddd2cb846ed2ceeda /activerecord/test/cases
parentd1e36842ba8f3eb723fd65535cf292c898c73b68 (diff)
downloadrails-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/cases')
-rw-r--r--activerecord/test/cases/associations/has_many_associations_test.rb12
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