@@ -344,8 +344,8 class Issue < ActiveRecord::Base | |||
|
344 | 344 | # fixed_version that is outside of the issue's project hierarchy. |
|
345 | 345 | # |
|
346 | 346 | # OPTIMIZE: does a full table scan of Issues with a fixed_version. |
|
347 |
def self.update_fixed_versions_from_ |
|
|
348 |
Issue.all(:conditions => |
|
|
347 | def self.update_fixed_versions_from_sharing_change(conditions=nil) | |
|
348 | Issue.all(:conditions => merge_conditions('fixed_version_id IS NOT NULL', conditions), | |
|
349 | 349 | :include => [:project, :fixed_version] |
|
350 | 350 | ).each do |issue| |
|
351 | 351 | next if issue.project.nil? || issue.fixed_version.nil? |
@@ -304,7 +304,7 class Project < ActiveRecord::Base | |||
|
304 | 304 | # move_to_child_of adds the project in last (ie.right) position |
|
305 | 305 | move_to_child_of(p) |
|
306 | 306 | end |
|
307 |
Issue.update_fixed_versions_from_ |
|
|
307 | Issue.update_fixed_versions_from_sharing_change | |
|
308 | 308 | true |
|
309 | 309 | else |
|
310 | 310 | # Can not move to the given target |
@@ -17,7 +17,7 | |||
|
17 | 17 | |
|
18 | 18 | class Version < ActiveRecord::Base |
|
19 | 19 | before_destroy :check_integrity |
|
20 |
after_update :update_issue |
|
|
20 | after_update :update_issues_from_sharing_change | |
|
21 | 21 | belongs_to :project |
|
22 | 22 | has_many :fixed_issues, :class_name => 'Issue', :foreign_key => 'fixed_version_id' |
|
23 | 23 | acts_as_customizable |
@@ -161,9 +161,13 private | |||
|
161 | 161 | end |
|
162 | 162 | |
|
163 | 163 | # Update the issue's fixed versions. Used if a version's sharing changes. |
|
164 |
def update_issue |
|
|
164 | def update_issues_from_sharing_change | |
|
165 | 165 | if sharing_changed? |
|
166 | Issue.update_fixed_versions_from_project_hierarchy_change | |
|
166 | if VERSION_SHARINGS.index(sharing_was).nil? || | |
|
167 | VERSION_SHARINGS.index(sharing).nil? || | |
|
168 | VERSION_SHARINGS.index(sharing_was) > VERSION_SHARINGS.index(sharing) | |
|
169 | Issue.update_fixed_versions_from_sharing_change ['fixed_version_id = ?', id] | |
|
170 | end | |
|
167 | 171 | end |
|
168 | 172 | end |
|
169 | 173 |
General Comments 0
You need to be logged in to leave comments.
Login now