diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2013-12-17 21:45:55 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2013-12-17 21:45:55 -0700 |
commit | c141dfc838a5dca9f197814410fa5d44c143129c (patch) | |
tree | 649ac346e2ccf8907045e8d5221c807e6a217995 /activerecord | |
parent | b6415428c863dd8148ef9b5998c8a29738c28afd (diff) | |
download | rails-c141dfc838a5dca9f197814410fa5d44c143129c.tar.gz rails-c141dfc838a5dca9f197814410fa5d44c143129c.tar.bz2 rails-c141dfc838a5dca9f197814410fa5d44c143129c.zip |
Add a failing test for assigning nil to a polymorphic belongs_to not nullifying its _type column
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/test/cases/associations/belongs_to_associations_test.rb | 13 |
1 files changed, 13 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 7c913bc78b..6d01fcf50c 100644 --- a/activerecord/test/cases/associations/belongs_to_associations_test.rb +++ b/activerecord/test/cases/associations/belongs_to_associations_test.rb @@ -578,6 +578,19 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase assert_nil essay.writer_id end + def test_polymorphic_assignment_with_nil + essay = Essay.new + assert_nil essay.writer_id + assert_nil essay.writer_type + + essay.writer_id = 1 + essay.writer_type = 'Author' + + essay.writer = nil + assert_nil essay.writer_id + assert_nil essay.writer_type + end + def test_belongs_to_proxy_should_not_respond_to_private_methods assert_raise(NoMethodError) { companies(:first_firm).private_method } assert_raise(NoMethodError) { companies(:second_client).firm.private_method } |