mirror of
https://github.com/meineerde/redmine.git
synced 2026-01-31 11:37:14 +00:00
Destroy overridden time entry activities and rows from the habtm join table @queries_roles@ on project deletion (#36416).
Patch by Holger Just. git-svn-id: http://svn.redmine.org/redmine/trunk@21437 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
1db2566ff9
commit
96d32a5226
@ -30,7 +30,7 @@ class Project < ActiveRecord::Base
|
||||
IDENTIFIER_MAX_LENGTH = 100
|
||||
|
||||
# Specific overridden Activities
|
||||
has_many :time_entry_activities
|
||||
has_many :time_entry_activities, :dependent => :destroy
|
||||
has_many :memberships, :class_name => 'Member', :inverse_of => :project
|
||||
# Memberships of active users only
|
||||
has_many :members,
|
||||
@ -43,7 +43,7 @@ class Project < ActiveRecord::Base
|
||||
belongs_to :default_version, :class_name => 'Version'
|
||||
belongs_to :default_assigned_to, :class_name => 'Principal'
|
||||
has_many :time_entries, :dependent => :destroy
|
||||
has_many :queries, :dependent => :delete_all
|
||||
has_many :queries, :dependent => :destroy
|
||||
has_many :documents, :dependent => :destroy
|
||||
has_many :news, lambda {includes(:author)}, :dependent => :destroy
|
||||
has_many :issue_categories, lambda {order(:name)}, :dependent => :delete_all
|
||||
|
||||
@ -233,6 +233,12 @@ class ProjectTest < ActiveSupport::TestCase
|
||||
# some boards
|
||||
assert @ecookbook.boards.any?
|
||||
|
||||
# generate some dependent objects
|
||||
overridden_activity = TimeEntryActivity.new({:name => "Project", :project => @ecookbook})
|
||||
assert overridden_activity.save!
|
||||
|
||||
query = IssueQuery.generate!(:project => @ecookbook, :visibility => Query::VISIBILITY_ROLES, :roles => Role.where(:id => [1, 3]).to_a)
|
||||
|
||||
@ecookbook.destroy
|
||||
# make sure that the project non longer exists
|
||||
assert_raise(ActiveRecord::RecordNotFound) {Project.find(@ecookbook.id)}
|
||||
@ -240,6 +246,10 @@ class ProjectTest < ActiveSupport::TestCase
|
||||
assert_not Member.where(:project_id => @ecookbook.id).exists?
|
||||
assert_not Board.where(:project_id => @ecookbook.id).exists?
|
||||
assert_not Issue.where(:project_id => @ecookbook.id).exists?
|
||||
assert_not Enumeration.where(:project_id => @ecookbook.id).exists?
|
||||
|
||||
assert_not Query.where(:project_id => @ecookbook.id).exists?
|
||||
assert_nil ActiveRecord::Base.connection.select_value("SELECT 1 FROM queries_roles WHERE query_id = #{query.id}")
|
||||
end
|
||||
|
||||
def test_destroy_should_destroy_subtasks
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user