diff options
author | José Valim <jose.valim@plataformatec.com.br> | 2013-08-14 23:55:33 -0700 |
---|---|---|
committer | José Valim <jose.valim@plataformatec.com.br> | 2013-08-14 23:55:33 -0700 |
commit | e90f0e0eb68825b7a07e2f468272a138107154c3 (patch) | |
tree | 167b7ecc14900b0ec78414e2e5bc53cc42acd874 /activerecord/test/cases/associations | |
parent | e6b9f130a658977e3f9ddce106d321b55af916b7 (diff) | |
parent | c9e2fa22cbf74f8184e502e7726fcfbe33bdb3e6 (diff) | |
download | rails-e90f0e0eb68825b7a07e2f468272a138107154c3.tar.gz rails-e90f0e0eb68825b7a07e2f468272a138107154c3.tar.bz2 rails-e90f0e0eb68825b7a07e2f468272a138107154c3.zip |
Merge pull request #11897 from wangjohn/fixing_multiple_word_inverse_detection
Fixing multi-word automatic inverse detection.
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r-- | activerecord/test/cases/associations/inverse_associations_test.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/inverse_associations_test.rb b/activerecord/test/cases/associations/inverse_associations_test.rb index ce78332124..2477e60e51 100644 --- a/activerecord/test/cases/associations/inverse_associations_test.rb +++ b/activerecord/test/cases/associations/inverse_associations_test.rb @@ -9,10 +9,24 @@ require 'models/rating' require 'models/comment' require 'models/car' require 'models/bulb' +require 'models/mixed_case_monkey' class AutomaticInverseFindingTests < ActiveRecord::TestCase fixtures :ratings, :comments, :cars + def test_has_one_and_belongs_to_should_find_inverse_automatically_on_multiple_word_name + monkey_reflection = MixedCaseMonkey.reflect_on_association(:man) + man_reflection = Man.reflect_on_association(:mixed_case_monkey) + + assert_respond_to monkey_reflection, :has_inverse? + assert monkey_reflection.has_inverse?, "The monkey reflection should have an inverse" + assert_equal man_reflection, monkey_reflection.inverse_of, "The monkey reflection's inverse should be the man reflection" + + assert_respond_to man_reflection, :has_inverse? + assert man_reflection.has_inverse?, "The man reflection should have an inverse" + assert_equal monkey_reflection, man_reflection.inverse_of, "The man reflection's inverse should be the monkey 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) |