mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-19 15:01:14 +00:00
Workflow editing shows statuses of irrelevant roles (#24281).
Patch by Jens Krämer. git-svn-id: http://svn.redmine.org/redmine/trunk@16081 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
af7ba4ad53
commit
68c7f4ef20
@ -138,7 +138,11 @@ class WorkflowsController < ApplicationController
|
|||||||
def find_statuses
|
def find_statuses
|
||||||
@used_statuses_only = (params[:used_statuses_only] == '0' ? false : true)
|
@used_statuses_only = (params[:used_statuses_only] == '0' ? false : true)
|
||||||
if @trackers && @used_statuses_only
|
if @trackers && @used_statuses_only
|
||||||
@statuses = @trackers.map(&:issue_statuses).flatten.uniq.sort.presence
|
role_ids = Role.all.select(&:consider_workflow?).map(&:id)
|
||||||
|
status_ids = WorkflowTransition.where(
|
||||||
|
:tracker_id => @trackers.map(&:id), :role_id => role_ids
|
||||||
|
).uniq.pluck(:old_status_id, :new_status_id).flatten.uniq
|
||||||
|
@statuses = IssueStatus.where(:id => status_ids).sorted.to_a.presence
|
||||||
end
|
end
|
||||||
@statuses ||= IssueStatus.sorted.to_a
|
@statuses ||= IssueStatus.sorted.to_a
|
||||||
end
|
end
|
||||||
|
|||||||
@ -59,6 +59,25 @@ class WorkflowsControllerTest < Redmine::ControllerTest
|
|||||||
assert_select 'input[type=checkbox][name=?]', 'transitions[1][1][always]', 0
|
assert_select 'input[type=checkbox][name=?]', 'transitions[1][1][always]', 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_get_edit_with_role_and_tracker_should_not_include_statuses_from_roles_without_workflow_permissions
|
||||||
|
WorkflowTransition.delete_all
|
||||||
|
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 2, :new_status_id => 3)
|
||||||
|
|
||||||
|
reporter = Role.find(3)
|
||||||
|
reporter.remove_permission! :edit_issues
|
||||||
|
reporter.remove_permission! :add_issues
|
||||||
|
assert !reporter.consider_workflow?
|
||||||
|
WorkflowTransition.create!(:role_id => 3, :tracker_id => 1, :old_status_id => 1, :new_status_id => 5)
|
||||||
|
|
||||||
|
get :edit, :params => {:role_id => 2, :tracker_id => 1}
|
||||||
|
assert_response :success
|
||||||
|
|
||||||
|
# statuses 1 and 5 not displayed
|
||||||
|
statuses = IssueStatus.where(:id => [2, 3]).sorted.pluck(:name)
|
||||||
|
assert_equal ["New issue"] + statuses,
|
||||||
|
css_select('table.workflows.transitions-always tbody tr td:first').map(&:text).map(&:strip)
|
||||||
|
end
|
||||||
|
|
||||||
def test_get_edit_should_include_allowed_statuses_for_new_issues
|
def test_get_edit_should_include_allowed_statuses_for_new_issues
|
||||||
WorkflowTransition.delete_all
|
WorkflowTransition.delete_all
|
||||||
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 0, :new_status_id => 1)
|
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 0, :new_status_id => 1)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user