diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-02-12 18:03:43 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-02-12 18:03:43 +0000 |
commit | a32a9863640dbd7a74b251e5467f90d134396110 (patch) | |
tree | 9749cf28832ec403227a8dc92bf06e336bfb5a58 /activerecord/test | |
parent | b230004897770ff8e29590263ddd6416b728af3a (diff) | |
download | rails-a32a9863640dbd7a74b251e5467f90d134396110.tar.gz rails-a32a9863640dbd7a74b251e5467f90d134396110.tar.bz2 rails-a32a9863640dbd7a74b251e5467f90d134396110.zip |
save polymorphic joins from the has_many|one association (closes #3812) [Rick Olson]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3586 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/associations_join_model_test.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/activerecord/test/associations_join_model_test.rb b/activerecord/test/associations_join_model_test.rb index 5437e049a3..5c1510faff 100644 --- a/activerecord/test/associations_join_model_test.rb +++ b/activerecord/test/associations_join_model_test.rb @@ -56,6 +56,28 @@ class AssociationsJoinModelTest < Test::Unit::TestCase assert_equal "Post", tagging.taggable_type end + def test_set_polymorphic_has_many + tagging = tags(:misc).taggings.create + posts(:thinking).taggings << tagging + assert_equal "Post", tagging.taggable_type + end + + def test_set_polymorphic_has_one + tagging = tags(:misc).taggings.create + posts(:thinking).tagging = tagging + assert_equal "Post", tagging.taggable_type + end + + def test_create_polymorphic_has_many_with_scope + tagging = posts(:welcome).taggings.create(:tag => tags(:general)) + assert_equal "Post", tagging.taggable_type + end + + def test_create_polymorphic_has_one_with_scope + tagging = posts(:welcome).tagging.create(:tag => tags(:general)) + assert_equal "Post", tagging.taggable_type + end + def test_has_many_with_piggyback assert_equal "2", categories(:sti_test).authors.first.post_id.to_s end |