aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Hawthorn <john.hawthorn@gmail.com>2010-11-28 20:07:59 -0800
committerJosé Valim <jose.valim@gmail.com>2010-11-29 10:48:48 +0100
commit28896a9f4ae0830726619bc479f69263acb80e4b (patch)
tree660ac50d9548f7b34349a29648cd2603f2590a6f
parente444439fe28f873c783a4b99b1c9f29a7405dd0d (diff)
downloadrails-28896a9f4ae0830726619bc479f69263acb80e4b.tar.gz
rails-28896a9f4ae0830726619bc479f69263acb80e4b.tar.bz2
rails-28896a9f4ae0830726619bc479f69263acb80e4b.zip
test case on has_one :through after a destroy
[#6037 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
-rw-r--r--activerecord/test/cases/associations/has_one_through_associations_test.rb17
1 files changed, 17 insertions, 0 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 5d153147f5..ac43e571cb 100644
--- a/activerecord/test/cases/associations/has_one_through_associations_test.rb
+++ b/activerecord/test/cases/associations/has_one_through_associations_test.rb
@@ -206,6 +206,23 @@ class HasOneThroughAssociationsTest < ActiveRecord::TestCase
end
end
+ def test_through_belongs_to_after_destroy
+ @member_detail = MemberDetail.new(:extra_data => 'Extra')
+ @member.member_detail = @member_detail
+ @member.save!
+
+ assert_not_nil @member_detail.member_type
+ @member_detail.destroy
+ assert_queries(1) do
+ assert_not_nil @member_detail.member_type(true)
+ end
+
+ @member_detail.member.destroy
+ assert_queries(1) do
+ assert_nil @member_detail.member_type(true)
+ end
+ end
+
def test_value_is_properly_quoted
minivan = Minivan.find('m1')
assert_nothing_raised do