Patch #37636 ยป 0001-Ignore-statuses-if-workflow-only-defines-identity-tr.patch
| app/controllers/workflows_controller.rb | ||
|---|---|---|
|
role_ids = Role.all.select(&:consider_workflow?).map(&:id)
|
||
|
status_ids = WorkflowTransition.where(
|
||
|
:tracker_id => @trackers.map(&:id), :role_id => role_ids
|
||
|
).where(
|
||
|
'old_status_id <> new_status_id'
|
||
|
).distinct.pluck(:old_status_id, :new_status_id).flatten.uniq
|
||
|
@statuses = IssueStatus.where(:id => status_ids).sorted.to_a.presence
|
||
|
end
|
||
| app/models/tracker.rb | ||
|---|---|---|
|
else
|
||
|
@issue_status_ids ||=
|
||
|
WorkflowTransition.where(:tracker_id => id).
|
||
|
where('old_status_id <> new_status_id').
|
||
|
distinct.pluck(:old_status_id, :new_status_id).flatten.uniq
|
||
|
end
|
||
|
end
|
||
| test/functional/workflows_controller_test.rb | ||
|---|---|---|
|
)
|
||
|
end
|
||
|
def test_get_edit_with_role_and_tracker_should_not_include_only_identity_workflows
|
||
|
WorkflowTransition.delete_all
|
||
|
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 1)
|
||
|
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 2, :new_status_id => 3)
|
||
|
get :edit, :params => {:role_id => 1, :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
|
||
|
WorkflowTransition.delete_all
|
||
|
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 0, :new_status_id => 1)
|
||
| test/unit/tracker_test.rb | ||
|---|---|---|
|
def test_issue_statuses
|
||
|
tracker = Tracker.find(1)
|
||
|
WorkflowTransition.delete_all
|
||
|
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 1)
|
||
|
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 2, :new_status_id => 3)
|
||
|
WorkflowTransition.create!(:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 5)
|
||