From f33dfe92436eb06b1e7f0d5a2ed28790b8d29c9d Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 26 Oct 2014 22:33:33 +0000 Subject: [PATCH] Code cleanup. git-svn-id: http://svn.redmine.org/redmine/trunk@13515 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/issue.rb | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/app/models/issue.rb b/app/models/issue.rb index 31b2d69f1..21a6be587 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -779,25 +779,30 @@ class Issue < ActiveRecord::Base initial_status = nil if new_record? initial_status = IssueStatus.default - elsif status_id_was - initial_status = IssueStatus.find_by_id(status_id_was) + else + initial_status = status_was end - initial_status ||= status initial_assigned_to_id = assigned_to_id_changed? ? assigned_to_id_was : assigned_to_id assignee_transitions_allowed = initial_assigned_to_id.present? && (user.id == initial_assigned_to_id || user.group_ids.include?(initial_assigned_to_id)) - statuses = initial_status.find_new_statuses_allowed_to( - user.admin ? Role.all : user.roles_for_project(project), - tracker, - author == user, - assignee_transitions_allowed - ) + statuses = [] + if initial_status + statuses += initial_status.find_new_statuses_allowed_to( + user.admin ? Role.all.to_a : user.roles_for_project(project), + tracker, + author == user, + assignee_transitions_allowed + ) + end statuses << initial_status unless statuses.empty? statuses << IssueStatus.default if include_default statuses = statuses.compact.uniq.sort - blocked? ? statuses.reject {|s| s.is_closed?} : statuses + if blocked? + statuses.reject!(&:is_closed?) + end + statuses end end -- 2.39.5