diff options
author | Jamis Buck <jamis@37signals.com> | 2006-01-20 21:51:48 +0000 |
---|---|---|
committer | Jamis Buck <jamis@37signals.com> | 2006-01-20 21:51:48 +0000 |
commit | f9c13e6134bbc32dd826eec39fedba5de2514f88 (patch) | |
tree | f58cbeb77de93e1fa229b191b91e03913163770a | |
parent | d2f47503f8890fe42310ada8ca9408ac5f268265 (diff) | |
download | rails-f9c13e6134bbc32dd826eec39fedba5de2514f88.tar.gz rails-f9c13e6134bbc32dd826eec39fedba5de2514f88.tar.bz2 rails-f9c13e6134bbc32dd826eec39fedba5de2514f88.zip |
Add a test to verify correct behavior when creating a polymorphic association
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3440 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | activerecord/test/associations_join_model_test.rb | 8 | ||||
-rw-r--r-- | activerecord/test/fixtures/tag.rb | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/test/associations_join_model_test.rb b/activerecord/test/associations_join_model_test.rb index f8d8b77813..a011a0fae8 100644 --- a/activerecord/test/associations_join_model_test.rb +++ b/activerecord/test/associations_join_model_test.rb @@ -39,6 +39,14 @@ class AssociationsJoinModelTest < Test::Unit::TestCase assert_equal tags(:general), posts(:thinking).tags.first end + def test_polymorphic_has_many_create_model_with_inheritance + post = posts(:thinking) + assert_instance_of SpecialPost, post + + tagging = tags(:misc).taggings.create(:taggable => post) + 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 diff --git a/activerecord/test/fixtures/tag.rb b/activerecord/test/fixtures/tag.rb index bfd81c69f7..d54f3cd680 100644 --- a/activerecord/test/fixtures/tag.rb +++ b/activerecord/test/fixtures/tag.rb @@ -1,2 +1,3 @@ class Tag < ActiveRecord::Base + has_many :taggings, :as => :taggable end
\ No newline at end of file |