diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2011-05-21 09:43:42 -0700 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2011-05-21 09:43:42 -0700 |
commit | da8469fa7dc5caffc69b5407ac0d94183a72c09e (patch) | |
tree | c8d380c029bfe47199a928faf06e362ce2447872 /activerecord/test/cases | |
parent | eba978ca501ad2ad529b91aba488ecb64ee44e7f (diff) | |
parent | 1c614bcb0fb65f0a5541263deacda498e52f447b (diff) | |
download | rails-da8469fa7dc5caffc69b5407ac0d94183a72c09e.tar.gz rails-da8469fa7dc5caffc69b5407ac0d94183a72c09e.tar.bz2 rails-da8469fa7dc5caffc69b5407ac0d94183a72c09e.zip |
Merge pull request #1187 from thedarkone/polymorphic-class-fix
Handle polymorphic_type NOT NULL columns
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/associations/belongs_to_associations_test.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/belongs_to_associations_test.rb b/activerecord/test/cases/associations/belongs_to_associations_test.rb index b993bf6e90..5a900e0605 100644 --- a/activerecord/test/cases/associations/belongs_to_associations_test.rb +++ b/activerecord/test/cases/associations/belongs_to_associations_test.rb @@ -158,6 +158,17 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase assert_not_nil Company.find(3).firm_with_condition, "Microsoft should have a firm" end + def test_polymorphic_association_class + sponsor = Sponsor.new + assert_nil sponsor.association(:sponsorable).send(:klass) + + sponsor.sponsorable_type = '' # the column doesn't have to be declared NOT NULL + assert_nil sponsor.association(:sponsorable).send(:klass) + + sponsor.sponsorable = Member.new :name => "Bert" + assert_equal Member, sponsor.association(:sponsorable).send(:klass) + end + def test_with_polymorphic_and_condition sponsor = Sponsor.create member = Member.create :name => "Bert" |