private
+ # Deletes repository data
def clear_changesets
- cs, ch, ci = Changeset.table_name, Change.table_name, "#{table_name_prefix}changesets_issues#{table_name_suffix}"
+ cs = Changeset.table_name
+ ch = Change.table_name
+ ci = "#{table_name_prefix}changesets_issues#{table_name_suffix}"
+ cp = "#{table_name_prefix}changeset_parents#{table_name_suffix}"
+
connection.delete("DELETE FROM #{ch} WHERE #{ch}.changeset_id IN (SELECT #{cs}.id FROM #{cs} WHERE #{cs}.repository_id = #{id})")
connection.delete("DELETE FROM #{ci} WHERE #{ci}.changeset_id IN (SELECT #{cs}.id FROM #{cs} WHERE #{cs}.repository_id = #{id})")
+ connection.delete("DELETE FROM #{cp} WHERE #{cp}.changeset_id IN (SELECT #{cs}.id FROM #{cs} WHERE #{cs}.repository_id = #{id})")
connection.delete("DELETE FROM #{cs} WHERE #{cs}.repository_id = #{id}")
end
end
end
end
+ def test_destroy_should_delete_parents_associations
+ changeset = Changeset.find(102)
+ changeset.parents = Changeset.find_all_by_id([100, 101])
+
+ assert_difference 'Changeset.connection.select_all("select * from changeset_parents").size', -2 do
+ Repository.find(10).destroy
+ end
+ end
+
def test_should_not_create_with_disabled_scm
# disable Subversion
with_settings :enabled_scm => ['Darcs', 'Git'] do