@@ -56,7 +56,7 class Project < ActiveRecord::Base | |||
|
56 | 56 | :join_table => "#{table_name_prefix}custom_fields_projects#{table_name_suffix}", |
|
57 | 57 | :association_foreign_key => 'custom_field_id' |
|
58 | 58 | |
|
59 | acts_as_nested_set :order => 'name' | |
|
59 | acts_as_nested_set :order => 'name', :dependent => :destroy | |
|
60 | 60 | acts_as_attachable :view_permission => :view_files, |
|
61 | 61 | :delete_permission => :manage_files |
|
62 | 62 | |
@@ -79,7 +79,7 class Project < ActiveRecord::Base | |||
|
79 | 79 | # reserved words |
|
80 | 80 | validates_exclusion_of :identifier, :in => %w( new ) |
|
81 | 81 | |
|
82 |
before_destroy :delete_all_members |
|
|
82 | before_destroy :delete_all_members | |
|
83 | 83 | |
|
84 | 84 | named_scope :has_module, lambda { |mod| { :conditions => ["#{Project.table_name}.id IN (SELECT em.project_id FROM #{EnabledModule.table_name} em WHERE em.name=?)", mod.to_s] } } |
|
85 | 85 | named_scope :active, { :conditions => "#{Project.table_name}.status = #{STATUS_ACTIVE}"} |
@@ -627,13 +627,6 class Project < ActiveRecord::Base | |||
|
627 | 627 | |
|
628 | 628 | private |
|
629 | 629 | |
|
630 | # Destroys children before destroying self | |
|
631 | def destroy_children | |
|
632 | children.each do |child| | |
|
633 | child.destroy | |
|
634 | end | |
|
635 | end | |
|
636 | ||
|
637 | 630 | # Copies wiki from +project+ |
|
638 | 631 | def copy_wiki(project) |
|
639 | 632 | # Check that the source project has a wiki first |
@@ -1,5 +1,5 | |||
|
1 |
# |
|
|
2 |
# Copyright (C) 2006-20 |
|
|
1 | # Redmine - project management software | |
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
@@ -182,6 +182,41 class ProjectTest < ActiveSupport::TestCase | |||
|
182 | 182 | assert_nil Issue.first(:conditions => {:project_id => @ecookbook.id}) |
|
183 | 183 | end |
|
184 | 184 | |
|
185 | def test_destroying_root_projects_should_clear_data | |
|
186 | Project.roots.each do |root| | |
|
187 | root.destroy | |
|
188 | end | |
|
189 | ||
|
190 | assert_equal 0, Project.count, "Projects were not deleted: #{Project.all.inspect}" | |
|
191 | assert_equal 0, Member.count, "Members were not deleted: #{Member.all.inspect}" | |
|
192 | assert_equal 0, MemberRole.count | |
|
193 | assert_equal 0, Issue.count | |
|
194 | assert_equal 0, Journal.count | |
|
195 | assert_equal 0, JournalDetail.count | |
|
196 | assert_equal 0, Attachment.count | |
|
197 | assert_equal 0, EnabledModule.count | |
|
198 | assert_equal 0, IssueCategory.count | |
|
199 | assert_equal 0, IssueRelation.count | |
|
200 | assert_equal 0, Board.count | |
|
201 | assert_equal 0, Message.count | |
|
202 | assert_equal 0, News.count | |
|
203 | assert_equal 0, Query.count(:conditions => "project_id IS NOT NULL") | |
|
204 | assert_equal 0, Repository.count | |
|
205 | assert_equal 0, Changeset.count | |
|
206 | assert_equal 0, Change.count | |
|
207 | #assert_equal 0, Comment.count | |
|
208 | assert_equal 0, TimeEntry.count | |
|
209 | assert_equal 0, Version.count | |
|
210 | assert_equal 0, Watcher.count | |
|
211 | assert_equal 0, Wiki.count | |
|
212 | assert_equal 0, WikiPage.count | |
|
213 | assert_equal 0, WikiContent.count | |
|
214 | assert_equal 0, WikiContent::Version.count | |
|
215 | assert_equal 0, Project.connection.select_all("SELECT * FROM projects_trackers").size | |
|
216 | assert_equal 0, Project.connection.select_all("SELECT * FROM custom_fields_projects").size | |
|
217 | assert_equal 0, CustomValue.count(:conditions => {:customized_type => ['Project', 'Issue', 'TimeEntry', 'Version']}) | |
|
218 | end | |
|
219 | ||
|
185 | 220 | def test_move_an_orphan_project_to_a_root_project |
|
186 | 221 | sub = Project.find(2) |
|
187 | 222 | sub.set_parent! @ecookbook |
General Comments 0
You need to be logged in to leave comments.
Login now