Permalink
Browse files

fix #delete_all with habtm with :delete_sql

  • Loading branch information...
jonleighton committed May 18, 2012
1 parent a1dd008 commit dcc576df8f4e6dfb2ef9891454b771c7d47ea219
@@ -40,6 +40,7 @@ def count_records
def delete_records(records, method)
if sql = options[:delete_sql]
+ records = load_target if records == :all
records.each { |record| owner.connection.delete(interpolate(sql, record)) }
else
relation = join_table
@@ -380,6 +380,12 @@ def test_deleting_array_with_sql
assert_equal 0, active_record.developers_by_sql(true).size
end
+ def test_deleting_all_with_sql
+ project = Project.find(1)
+ project.developers_by_sql.delete_all
+ assert_equal 0, project.developers_by_sql.size
+ end
+
def test_deleting_all
david = Developer.find(1)
david.projects.reload

0 comments on commit dcc576d

Please sign in to comment.