Fixed that changesets parents associations are not deleted when deleting a repository.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8847 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
17d5118de6
commit
8f92121606
|
@ -403,10 +403,16 @@ class Repository < ActiveRecord::Base
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
# Deletes repository data
|
||||||
def clear_changesets
|
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 #{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 #{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}")
|
connection.delete("DELETE FROM #{cs} WHERE #{cs}.repository_id = #{id}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -74,6 +74,15 @@ class RepositoryTest < ActiveSupport::TestCase
|
||||||
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
|
def test_should_not_create_with_disabled_scm
|
||||||
# disable Subversion
|
# disable Subversion
|
||||||
with_settings :enabled_scm => ['Darcs', 'Git'] do
|
with_settings :enabled_scm => ['Darcs', 'Git'] do
|
||||||
|
|
Loading…
Reference in New Issue