From 8fb245dd6a185b75e3d47c235d2e84e58046108d Mon Sep 17 00:00:00 2001 From: hjust Date: Thu, 25 Feb 2010 17:51:47 +0000 Subject: [PATCH] Compatibility: Set cost_object to nil on issue move if the current cost object would be invalid in the new issue location git-svn-id: https://dev.finn.de/svn/cockpit/trunk@536 7926756e-e54e-46e6-9721-ed318f58905e --- lib/costs_issue_observer.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/costs_issue_observer.rb b/lib/costs_issue_observer.rb index 656abdd6d0..4ae08bbed4 100644 --- a/lib/costs_issue_observer.rb +++ b/lib/costs_issue_observer.rb @@ -6,5 +6,12 @@ class CostsIssueObserver < ActiveRecord::Observer CostEntry.update_all({:project_id => issue.project_id}, {:issue_id => id}) end end + + def before_update(issue) + # FIXME: remove this method once controller_issues_move_before_save is in 0.9-stable + if issue.project_id_changed? && issue.cost_object_id && !issue.project.cost_object_ids.include?(issue.cost_object_id) + issue.cost_object = nil + end + end end \ No newline at end of file