code cleanup: rubocop: fix Lint/IneffectiveAccessModifier in app/models/issue.rb

git-svn-id: http://svn.redmine.org/redmine/trunk@18780 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA
2019-10-19 13:33:43 +00:00
parent fd7675adf2
commit 75d3e4037b
2 changed files with 18 additions and 16 deletions

View File

@@ -391,7 +391,6 @@ Lint/HandleExceptions:
Lint/IneffectiveAccessModifier: Lint/IneffectiveAccessModifier:
Exclude: Exclude:
- 'app/models/attachment.rb' - 'app/models/attachment.rb'
- 'app/models/issue.rb'
- 'app/models/mail_handler.rb' - 'app/models/mail_handler.rb'
Lint/InterpolationCheck: Lint/InterpolationCheck:

View File

@@ -1724,21 +1724,24 @@ class Issue < ActiveRecord::Base
end end
end end
# Update issues so their versions are not pointing to a # Singleton class method is public
# fixed_version that is not shared with the issue's project class << self
def self.update_versions(conditions=nil) # Update issues so their versions are not pointing to a
# Only need to update issues with a fixed_version from # fixed_version that is not shared with the issue's project
# a different project and that is not systemwide shared def update_versions(conditions=nil)
Issue.joins(:project, :fixed_version). # Only need to update issues with a fixed_version from
where("#{Issue.table_name}.fixed_version_id IS NOT NULL" + # a different project and that is not systemwide shared
" AND #{Issue.table_name}.project_id <> #{Version.table_name}.project_id" + Issue.joins(:project, :fixed_version).
" AND #{Version.table_name}.sharing <> 'system'"). where("#{Issue.table_name}.fixed_version_id IS NOT NULL" +
where(conditions).each do |issue| " AND #{Issue.table_name}.project_id <> #{Version.table_name}.project_id" +
next if issue.project.nil? || issue.fixed_version.nil? " AND #{Version.table_name}.sharing <> 'system'").
unless issue.project.shared_versions.include?(issue.fixed_version) where(conditions).each do |issue|
issue.init_journal(User.current) next if issue.project.nil? || issue.fixed_version.nil?
issue.fixed_version = nil unless issue.project.shared_versions.include?(issue.fixed_version)
issue.save issue.init_journal(User.current)
issue.fixed_version = nil
issue.save
end
end end
end end
end end