Defect #37635 » 0001-Consider-only-roles-with-either-add_issues-or-edit_i.patch
| app/models/issue.rb | ||
|---|---|---|
| 1064 | 1064 |
(user.id == initial_assigned_to_id || user.group_ids.include?(initial_assigned_to_id)) |
| 1065 | 1065 | |
| 1066 | 1066 |
statuses = [] |
| 1067 | ||
| 1068 |
roles = user.admin ? Role.all.to_a : user.roles_for_project(project) |
|
| 1069 |
roles = roles.select(&:consider_workflow?) |
|
| 1067 | 1070 |
statuses += IssueStatus.new_statuses_allowed( |
| 1068 | 1071 |
initial_status, |
| 1069 |
user.admin ? Role.all.to_a : user.roles_for_project(project),
|
|
| 1072 |
roles,
|
|
| 1070 | 1073 |
tracker, |
| 1071 | 1074 |
author == user, |
| 1072 | 1075 |
assignee_transitions_allowed |
| test/unit/issue_test.rb | ||
|---|---|---|
| 859 | 859 |
assert_equal expected_statuses, issue.new_statuses_allowed_to(admin) |
| 860 | 860 |
end |
| 861 | 861 | |
| 862 |
def test_new_statuses_allowed_to_should_only_return_transitions_of_considered_workflows |
|
| 863 |
issue = Issue.find(9) |
|
| 864 | ||
| 865 |
WorkflowTransition.delete_all |
|
| 866 |
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 2) |
|
| 867 | ||
| 868 |
developer = Role.find(2) |
|
| 869 |
developer.remove_permission! :edit_issues |
|
| 870 |
developer.remove_permission! :add_issues |
|
| 871 |
assert !developer.consider_workflow? |
|
| 872 |
WorkflowTransition.create!(:role_id => 2, :tracker_id => 1, :old_status_id => 1, :new_status_id => 3) |
|
| 873 | ||
| 874 |
# status 3 is not displayed |
|
| 875 |
expected_statuses = IssueStatus.where(:id => [1, 2]) |
|
| 876 | ||
| 877 |
admin = User.find(1) |
|
| 878 |
assert_equal expected_statuses, issue.new_statuses_allowed_to(admin) |
|
| 879 | ||
| 880 |
author = User.find(8) |
|
| 881 |
assert_equal expected_statuses, issue.new_statuses_allowed_to(author) |
|
| 882 |
end |
|
| 883 | ||
| 862 | 884 |
def test_new_statuses_allowed_to_should_return_allowed_statuses_when_copying |
| 863 | 885 |
Tracker.find(1).generate_transitions! :role_id => 1, :clear => true, 0 => [1, 3] |
| 864 | 886 | |