summaryrefslogtreecommitdiffstats
path: root/app/models/issue_status.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/issue_status.rb')
-rw-r--r--app/models/issue_status.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/app/models/issue_status.rb b/app/models/issue_status.rb
index 337aa5894..de8a1391e 100644
--- a/app/models/issue_status.rb
+++ b/app/models/issue_status.rb
@@ -38,16 +38,18 @@ class IssueStatus < ActiveRecord::Base
# Returns an array of all statuses the given role can switch to
# Uses association cache when called more than one time
def new_statuses_allowed_to(role, tracker)
- new_statuses = [self] + workflows.select {|w| w.role_id == role.id && w.tracker_id == tracker.id}.collect{|w| w.new_status}
+ new_statuses = [self]
+ new_statuses += workflows.select {|w| w.role_id == role.id && w.tracker_id == tracker.id}.collect{|w| w.new_status} if role && tracker
new_statuses.sort{|x, y| x.position <=> y.position }
end
# Same thing as above but uses a database query
# More efficient than the previous method if called just once
def find_new_statuses_allowed_to(role, tracker)
- new_statuses = [self] + workflows.find(:all,
- :include => :new_status,
- :conditions => ["role_id=? and tracker_id=?", role.id, tracker.id]).collect{ |w| w.new_status }
+ new_statuses = [self]
+ new_statuses += workflows.find(:all,
+ :include => :new_status,
+ :conditions => ["role_id=? and tracker_id=?", role.id, tracker.id]).collect{ |w| w.new_status } if role && tracker
new_statuses.sort{|x, y| x.position <=> y.position }
end