@@ -539,6 +539,7 class Issue < ActiveRecord::Base | |||
|
539 | 539 | |
|
540 | 540 | user_real = user || User.current |
|
541 | 541 | roles = user_real.admin ? Role.all.to_a : user_real.roles_for_project(project) |
|
542 | roles = roles.select(&:consider_workflow?) | |
|
542 | 543 | return {} if roles.empty? |
|
543 | 544 | |
|
544 | 545 | result = {} |
@@ -113,6 +113,10 class Role < ActiveRecord::Base | |||
|
113 | 113 | !permissions.nil? && permissions.include?(perm.to_sym) |
|
114 | 114 | end |
|
115 | 115 | |
|
116 | def consider_workflow? | |
|
117 | has_permission?(:add_issues) || has_permission?(:edit_issues) | |
|
118 | end | |
|
119 | ||
|
116 | 120 | def <=>(role) |
|
117 | 121 | if role |
|
118 | 122 | if builtin == role.builtin |
@@ -914,6 +914,29 class IssueTest < ActiveSupport::TestCase | |||
|
914 | 914 | assert_equal %w(due_date), issue.read_only_attribute_names(user) |
|
915 | 915 | end |
|
916 | 916 | |
|
917 | def test_workflow_rules_should_ignore_roles_without_issue_permissions | |
|
918 | role = Role.generate! :permissions => [:view_issues, :edit_issues] | |
|
919 | ignored_role = Role.generate! :permissions => [:view_issues] | |
|
920 | ||
|
921 | WorkflowPermission.delete_all | |
|
922 | WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, | |
|
923 | :role => role, :field_name => 'due_date', | |
|
924 | :rule => 'required') | |
|
925 | WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, | |
|
926 | :role => role, :field_name => 'start_date', | |
|
927 | :rule => 'readonly') | |
|
928 | WorkflowPermission.create!(:old_status_id => 1, :tracker_id => 1, | |
|
929 | :role => role, :field_name => 'done_ratio', | |
|
930 | :rule => 'readonly') | |
|
931 | user = User.generate! | |
|
932 | User.add_to_project user, Project.find(1), [role, ignored_role] | |
|
933 | ||
|
934 | issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1) | |
|
935 | ||
|
936 | assert_equal %w(due_date), issue.required_attribute_names(user) | |
|
937 | assert_equal %w(done_ratio start_date), issue.read_only_attribute_names(user).sort | |
|
938 | end | |
|
939 | ||
|
917 | 940 | def test_copy |
|
918 | 941 | issue = Issue.new.copy_from(1) |
|
919 | 942 | assert issue.copy? |
General Comments 0
You need to be logged in to leave comments.
Login now