summaryrefslogtreecommitdiffstats
path: root/app/models/issue.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-04-09 09:39:27 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-04-09 09:39:27 +0000
commitea307619beceb51d6b9229987480e051f53b67d6 (patch)
treec207f141fbcb94e6bdd5449e3806afe0f322dfde /app/models/issue.rb
parent6d62ab64e6aa2eda3a7da481779821281bde16d9 (diff)
downloadredmine-ea307619beceb51d6b9229987480e051f53b67d6.tar.gz
redmine-ea307619beceb51d6b9229987480e051f53b67d6.zip
Fixed that improper statuses are proposed when changing status before tracker on the issue form (#10619).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9378 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/issue.rb')
-rw-r--r--app/models/issue.rb16
1 files changed, 12 insertions, 4 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb
index f85ddfec4..ec8c45d34 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -509,17 +509,25 @@ class Issue < ActiveRecord::Base
!relations_to.detect {|ir| ir.relation_type == 'blocks' && !ir.issue_from.closed?}.nil?
end
- # Returns an array of status that user is able to apply
+ # Returns an array of statuses that user is able to apply
def new_statuses_allowed_to(user=User.current, include_default=false)
- statuses = status.find_new_statuses_allowed_to(
+ initial_status = nil
+ if new_record?
+ initial_status = IssueStatus.default
+ elsif status_id_was
+ initial_status = IssueStatus.find_by_id(status_id_was)
+ end
+ initial_status ||= status
+
+ statuses = initial_status.find_new_statuses_allowed_to(
user.admin ? Role.all : user.roles_for_project(project),
tracker,
author == user,
assigned_to_id_changed? ? assigned_to_id_was == user.id : assigned_to_id == user.id
)
- statuses << status unless statuses.empty?
+ statuses << initial_status unless statuses.empty?
statuses << IssueStatus.default if include_default
- statuses = statuses.uniq.sort
+ statuses = statuses.compact.uniq.sort
blocked? ? statuses.reject {|s| s.is_closed?} : statuses
end