# fixed_version that is outside of the issue's project hierarchy.
#
# OPTIMIZE: does a full table scan of Issues with a fixed_version.
- def self.update_fixed_versions_from_project_hierarchy_change
- Issue.all(:conditions => ['fixed_version_id IS NOT NULL'],
+ def self.update_fixed_versions_from_sharing_change(conditions=nil)
+ Issue.all(:conditions => merge_conditions('fixed_version_id IS NOT NULL', conditions),
:include => [:project, :fixed_version]
).each do |issue|
next if issue.project.nil? || issue.fixed_version.nil?
# move_to_child_of adds the project in last (ie.right) position
move_to_child_of(p)
end
- Issue.update_fixed_versions_from_project_hierarchy_change
+ Issue.update_fixed_versions_from_sharing_change
true
else
# Can not move to the given target
class Version < ActiveRecord::Base
before_destroy :check_integrity
- after_update :update_issue_versions
+ after_update :update_issues_from_sharing_change
belongs_to :project
has_many :fixed_issues, :class_name => 'Issue', :foreign_key => 'fixed_version_id'
acts_as_customizable
end
# Update the issue's fixed versions. Used if a version's sharing changes.
- def update_issue_versions
+ def update_issues_from_sharing_change
if sharing_changed?
- Issue.update_fixed_versions_from_project_hierarchy_change
+ if VERSION_SHARINGS.index(sharing_was).nil? ||
+ VERSION_SHARINGS.index(sharing).nil? ||
+ VERSION_SHARINGS.index(sharing_was) > VERSION_SHARINGS.index(sharing)
+ Issue.update_fixed_versions_from_sharing_change ['fixed_version_id = ?', id]
+ end
end
end