aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorDaniel Guettler <daniel.guettler@gmail.com>2009-05-17 14:48:20 +0200
committerPratik Naik <pratiknaik@gmail.com>2009-05-17 14:48:20 +0200
commit25724eede9b5a62c74b3b78245944638f1cfcef4 (patch)
treee3c6606457fda47f35477c0e59cabc215931f0d4 /activerecord/test/cases
parenta9e8c4b37480564d27883dffe9134a9f95796a15 (diff)
downloadrails-25724eede9b5a62c74b3b78245944638f1cfcef4.tar.gz
rails-25724eede9b5a62c74b3b78245944638f1cfcef4.tar.bz2
rails-25724eede9b5a62c74b3b78245944638f1cfcef4.zip
has_one :through should not create a new association when assigned nil [#698 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/associations/has_one_through_associations_test.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/activerecord/test/cases/associations/has_one_through_associations_test.rb b/activerecord/test/cases/associations/has_one_through_associations_test.rb
index 12c598751b..ab6e6d20fc 100644
--- a/activerecord/test/cases/associations/has_one_through_associations_test.rb
+++ b/activerecord/test/cases/associations/has_one_through_associations_test.rb
@@ -43,7 +43,14 @@ class HasOneThroughAssociationsTest < ActiveRecord::TestCase
@member.reload
end
end
-
+
+ def test_set_record_to_nil_should_delete_association
+ @member.club = nil
+ @member.reload
+ assert_equal nil, @member.current_membership
+ assert_nil @member.club
+ end
+
def test_has_one_through_polymorphic
assert_equal clubs(:moustache_club), @member.sponsor_club
end