summaryrefslogtreecommitdiffstats
path: root/app/models/issue_status.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2010-07-25 10:48:27 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2010-07-25 10:48:27 +0000
commitc47d23a87be4e9de873d57ec2b843e8e7efc2caa (patch)
tree3543410323667da8b42d26c93229b274bce3673f /app/models/issue_status.rb
parent73d936803975a2f8edae1a3a2c4f7ae3943fde19 (diff)
downloadredmine-c47d23a87be4e9de873d57ec2b843e8e7efc2caa.tar.gz
redmine-c47d23a87be4e9de873d57ec2b843e8e7efc2caa.zip
Fixed: Deleting statuses doesn't delete all workflow entries (#5811).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3881 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/issue_status.rb')
-rw-r--r--app/models/issue_status.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/app/models/issue_status.rb b/app/models/issue_status.rb
index fdda12a8c..f376d5d15 100644
--- a/app/models/issue_status.rb
+++ b/app/models/issue_status.rb
@@ -17,8 +17,10 @@
class IssueStatus < ActiveRecord::Base
before_destroy :check_integrity
- has_many :workflows, :foreign_key => "old_status_id", :dependent => :delete_all
+ has_many :workflows, :foreign_key => "old_status_id"
acts_as_list
+
+ before_destroy :delete_workflows
validates_presence_of :name
validates_uniqueness_of :name
@@ -89,4 +91,9 @@ private
def check_integrity
raise "Can't delete status" if Issue.find(:first, :conditions => ["status_id=?", self.id])
end
+
+ # Deletes associated workflows
+ def delete_workflows
+ Workflow.delete_all(["old_status_id = :id OR new_status_id = :id", {:id => id}])
+ end
end