Defect #37635 » 0001-Consider-only-roles-with-either-add_issues-or-edit_i.patch
| app/models/issue.rb | ||
|---|---|---|
| 677 | 677 | def workflow_rule_by_attribute(user=nil) | 
| 678 | 678 | return @workflow_rule_by_attribute if @workflow_rule_by_attribute && user.nil? | 
| 679 | 679 | |
| 680 | user_real = user || User.current | |
| 681 | roles = user_real.admin ? Role.all.to_a : user_real.roles_for_project(project) | |
| 682 | roles = roles.select(&:consider_workflow?) | |
| 680 | roles = roles_for_workflow(user || User.current) | |
| 683 | 681 |     return {} if roles.empty? | 
| 684 | 682 | |
| 685 | 683 |     result = {} | 
| ... | ... | |
| 1066 | 1064 | statuses = [] | 
| 1067 | 1065 | statuses += IssueStatus.new_statuses_allowed( | 
| 1068 | 1066 | initial_status, | 
| 1069 |       user.admin ? Role.all.to_a : user.roles_for_project(project), | |
| 1067 |       roles_for_workflow(user), | |
| 1070 | 1068 | tracker, | 
| 1071 | 1069 | author == user, | 
| 1072 | 1070 | assignee_transitions_allowed | 
| ... | ... | |
| 2053 | 2051 | Project | 
| 2054 | 2052 | end | 
| 2055 | 2053 | end | 
| 2054 | ||
| 2055 | def roles_for_workflow(user) | |
| 2056 | roles = user.admin ? Role.all.to_a : user.roles_for_project(project) | |
| 2057 | roles.select(&:consider_workflow?) | |
| 2058 | end | |
| 2056 | 2059 | end | 
| 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 | |
- « Previous
- 1
- 2
- Next »