aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorthedarkone <thedarkone2@gmail.com>2011-05-21 15:18:09 +0200
committerthedarkone <thedarkone2@gmail.com>2011-05-21 15:18:09 +0200
commit1c614bcb0fb65f0a5541263deacda498e52f447b (patch)
tree883eb4cb1a741fdfb192db2de40bd233a10fc714 /activerecord/test
parent1a959ad72fc92a82e05e8c271858a64ed14b926e (diff)
downloadrails-1c614bcb0fb65f0a5541263deacda498e52f447b.tar.gz
rails-1c614bcb0fb65f0a5541263deacda498e52f447b.tar.bz2
rails-1c614bcb0fb65f0a5541263deacda498e52f447b.zip
Handle polymorphic_type NOT NULL-able columns as well.
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/associations/belongs_to_associations_test.rb11
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"