diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-01-01 18:18:54 +0000 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-03 16:24:30 -0800 |
commit | 16065b4f19b77111b7fec343969bcf98635e7e27 (patch) | |
tree | 6b6c9e642d9b97d262c691c3a5ae8a5edb043dfa /activerecord/test/cases/associations/belongs_to_associations_test.rb | |
parent | 60cf65def805995bcca184c40b44bb01d86a48aa (diff) | |
download | rails-16065b4f19b77111b7fec343969bcf98635e7e27.tar.gz rails-16065b4f19b77111b7fec343969bcf98635e7e27.tar.bz2 rails-16065b4f19b77111b7fec343969bcf98635e7e27.zip |
Some basic tests for the :foreign_type option on belongs_to, which was previously completely untested.
Diffstat (limited to 'activerecord/test/cases/associations/belongs_to_associations_test.rb')
-rw-r--r-- | activerecord/test/cases/associations/belongs_to_associations_test.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/belongs_to_associations_test.rb b/activerecord/test/cases/associations/belongs_to_associations_test.rb index f97f89b6fe..f697fdf628 100644 --- a/activerecord/test/cases/associations/belongs_to_associations_test.rb +++ b/activerecord/test/cases/associations/belongs_to_associations_test.rb @@ -579,4 +579,23 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase end end end + + def test_polymorphic_with_custom_foreign_type + sponsor = sponsors(:moustache_club_sponsor_for_groucho) + groucho = members(:groucho) + other = members(:some_other_guy) + + assert_equal groucho, sponsor.sponsorable + assert_equal groucho, sponsor.thing + + sponsor.thing = other + + assert_equal other, sponsor.sponsorable + assert_equal other, sponsor.thing + + sponsor.sponsorable = groucho + + assert_equal groucho, sponsor.sponsorable + assert_equal groucho, sponsor.thing + end end |