mirror of
https://github.com/github/rails.git
synced 2026-04-04 03:00:58 -04: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:
@@ -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
|
||||
Reference in New Issue
Block a user