From a32a9863640dbd7a74b251e5467f90d134396110 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 12 Feb 2006 18:03:43 +0000 Subject: 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 --- activerecord/test/associations_join_model_test.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'activerecord/test') 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 -- cgit v1.2.3