Permalink
Browse files

test case on has_one :through after a destroy

[#6037 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
1 parent 75015d1 commit 52e854e90025edfcf2c4665b81b17d3cd840f9d9 @jhawthorn jhawthorn committed with josevalim Nov 29, 2010
Showing with 17 additions and 0 deletions.
  1. +17 −0 activerecord/test/cases/associations/has_one_through_associations_test.rb
@@ -206,6 +206,23 @@ def test_save_of_record_with_loaded_has_one_through
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

0 comments on commit 52e854e

Please sign in to comment.