Skip to content

Commit

Permalink
Revert "Ensure HasManyThroughAssociation#destroy delete orphan records"
Browse files Browse the repository at this point in the history
This reverts commit 7a85927.

There's still some debate about the intended behaviour in the ticket, leaving in master but removing prior to shipping 2.3.3
  • Loading branch information
NZKoz committed Jun 9, 2009
1 parent 2c3d290 commit b1a044b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@ def create(attrs = nil)
end
end

def destroy(*records)
transaction do
delete_records(flatten_deeper(records))
super
end
end

# Returns the size of the collection by executing a SELECT COUNT(*) query if the collection hasn't been loaded and
# calling collection.size if it has. If it's more likely than not that the collection does have a size larger than zero,
# and you need to fetch that collection afterwards, it'll take one fewer SELECT query if you use #length.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def test_delete_association
end

def test_destroy_association
assert_difference ["Person.count", "Reader.count"], -1 do
assert_difference "Person.count", -1 do
posts(:welcome).people.destroy(people(:michael))
end

Expand All @@ -102,20 +102,14 @@ def test_destroy_association
end

def test_destroy_all
assert_difference ["Person.count", "Reader.count"], -1 do
assert_difference "Person.count", -1 do
posts(:welcome).people.destroy_all
end

assert posts(:welcome).reload.people.empty?
assert posts(:welcome).people(true).empty?
end

def test_should_raise_exception_for_destroying_mismatching_records
assert_no_difference ["Person.count", "Reader.count"] do
assert_raise(ActiveRecord::AssociationTypeMismatch) { posts(:welcome).people.destroy(posts(:thinking)) }
end
end

def test_replace_association
assert_queries(4){posts(:welcome);people(:david);people(:michael); posts(:welcome).people(true)}

Expand Down

0 comments on commit b1a044b

Please sign in to comment.