diff options
author | Andrew McCloud <andrew@amccloud.com> | 2014-06-15 16:15:32 -0700 |
---|---|---|
committer | Andrew McCloud <andrew@amccloud.com> | 2014-06-15 16:16:55 -0700 |
commit | 0bc6c2578635d5acedcfef90c8cd7a45fa5604c7 (patch) | |
tree | 365acd7f8d2fad577bc4310c40586652ef2806a4 /activerecord/test/cases/associations/inverse_associations_test.rb | |
parent | 952d0f8bdfa3f919794bf36049bafd2d95e3c97b (diff) | |
download | rails-0bc6c2578635d5acedcfef90c8cd7a45fa5604c7.tar.gz rails-0bc6c2578635d5acedcfef90c8cd7a45fa5604c7.tar.bz2 rails-0bc6c2578635d5acedcfef90c8cd7a45fa5604c7.zip |
Fixed automatic inverse_of for models nested in module
Diffstat (limited to 'activerecord/test/cases/associations/inverse_associations_test.rb')
-rw-r--r-- | activerecord/test/cases/associations/inverse_associations_test.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/inverse_associations_test.rb b/activerecord/test/cases/associations/inverse_associations_test.rb index 60df4e14dd..423b8238b1 100644 --- a/activerecord/test/cases/associations/inverse_associations_test.rb +++ b/activerecord/test/cases/associations/inverse_associations_test.rb @@ -10,6 +10,9 @@ require 'models/comment' require 'models/car' require 'models/bulb' require 'models/mixed_case_monkey' +require 'models/admin' +require 'models/admin/account' +require 'models/admin/user' class AutomaticInverseFindingTests < ActiveRecord::TestCase fixtures :ratings, :comments, :cars @@ -27,6 +30,15 @@ class AutomaticInverseFindingTests < ActiveRecord::TestCase assert_equal monkey_reflection, man_reflection.inverse_of, "The man reflection's inverse should be the monkey reflection" end + def test_has_many_and_belongs_to_should_find_inverse_automatically_for_model_in_module + account_reflection = Admin::Account.reflect_on_association(:users) + user_reflection = Admin::User.reflect_on_association(:account) + + assert_respond_to account_reflection, :has_inverse? + assert account_reflection.has_inverse?, "The Admin::Account reflection should have an inverse" + assert_equal user_reflection, account_reflection.inverse_of, "The Admin::Account reflection's inverse should be the Admin::User reflection" + end + def test_has_one_and_belongs_to_should_find_inverse_automatically car_reflection = Car.reflect_on_association(:bulb) bulb_reflection = Bulb.reflect_on_association(:car) |