mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
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
This commit is contained in:
parent
d2f47503f8
commit
f9c13e6134
2 changed files with 9 additions and 0 deletions
|
@ -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
|
||||
|
|
1
activerecord/test/fixtures/tag.rb
vendored
1
activerecord/test/fixtures/tag.rb
vendored
|
@ -1,2 +1,3 @@
|
|||
class Tag < ActiveRecord::Base
|
||||
has_many :taggings, :as => :taggable
|
||||
end
|
Loading…
Reference in a new issue