]> source.dussan.org Git - redmine.git/commitdiff
Code cleanup.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 26 Oct 2014 22:33:33 +0000 (22:33 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 26 Oct 2014 22:33:33 +0000 (22:33 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@13515 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/issue.rb

index 31b2d69f1b92a4960ce5e3e42bcf553f5c182bba..21a6be587fe9fc0862845f8c4852b0f5bdce8d24 100644 (file)
@@ -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