@@ -58,8 +58,7 class IssueStatus < ActiveRecord::Base | |||
|
58 | 58 | transitions = workflows.select do |w| |
|
59 | 59 | role_ids.include?(w.role_id) && |
|
60 | 60 | w.tracker_id == tracker.id && |
|
61 | (author || !w.author) && | |
|
62 | (assignee || !w.assignee) | |
|
61 | ((!w.author && !w.assignee) || (author && w.author) || (assignee && w.assignee)) | |
|
63 | 62 | end |
|
64 | 63 | transitions.collect{|w| w.new_status}.compact.sort |
|
65 | 64 | else |
@@ -70,14 +69,17 class IssueStatus < ActiveRecord::Base | |||
|
70 | 69 | # Same thing as above but uses a database query |
|
71 | 70 | # More efficient than the previous method if called just once |
|
72 | 71 | def find_new_statuses_allowed_to(roles, tracker, author=false, assignee=false) |
|
73 | if roles && tracker | |
|
74 | conditions = {:role_id => roles.collect(&:id), :tracker_id => tracker.id} | |
|
75 | conditions[:author] = false unless author | |
|
76 | conditions[:assignee] = false unless assignee | |
|
72 | if roles.present? && tracker | |
|
73 | conditions = "(author = :false AND assignee = :false)" | |
|
74 | conditions << " OR author = :true" if author | |
|
75 | conditions << " OR assignee = :true" if assignee | |
|
77 | 76 | |
|
78 | 77 | workflows.find(:all, |
|
79 | 78 |
|
|
80 | :conditions => conditions).collect{|w| w.new_status}.compact.sort | |
|
79 | :conditions => ["role_id IN (:role_ids) AND tracker_id = :tracker_id AND (#{conditions})", | |
|
80 | {:role_ids => roles.collect(&:id), :tracker_id => tracker.id, :true => true, :false => false} | |
|
81 | ] | |
|
82 | ).collect{|w| w.new_status}.compact.sort | |
|
81 | 83 | else |
|
82 | 84 | [] |
|
83 | 85 | end |
@@ -83,11 +83,11 class IssueStatusTest < ActiveSupport::TestCase | |||
|
83 | 83 | assert_equal [2], status.new_statuses_allowed_to([role], tracker, false, false).map(&:id) |
|
84 | 84 | assert_equal [2], status.find_new_statuses_allowed_to([role], tracker, false, false).map(&:id) |
|
85 | 85 | |
|
86 | assert_equal [2, 3], status.new_statuses_allowed_to([role], tracker, true, false).map(&:id) | |
|
87 | assert_equal [2, 3], status.find_new_statuses_allowed_to([role], tracker, true, false).map(&:id) | |
|
86 | assert_equal [2, 3, 5], status.new_statuses_allowed_to([role], tracker, true, false).map(&:id) | |
|
87 | assert_equal [2, 3, 5], status.find_new_statuses_allowed_to([role], tracker, true, false).map(&:id) | |
|
88 | 88 | |
|
89 | assert_equal [2, 4], status.new_statuses_allowed_to([role], tracker, false, true).map(&:id) | |
|
90 | assert_equal [2, 4], status.find_new_statuses_allowed_to([role], tracker, false, true).map(&:id) | |
|
89 | assert_equal [2, 4, 5], status.new_statuses_allowed_to([role], tracker, false, true).map(&:id) | |
|
90 | assert_equal [2, 4, 5], status.find_new_statuses_allowed_to([role], tracker, false, true).map(&:id) | |
|
91 | 91 | |
|
92 | 92 | assert_equal [2, 3, 4, 5], status.new_statuses_allowed_to([role], tracker, true, true).map(&:id) |
|
93 | 93 | assert_equal [2, 3, 4, 5], status.find_new_statuses_allowed_to([role], tracker, true, true).map(&:id) |
General Comments 0
You need to be logged in to leave comments.
Login now