Patch #37636 ยป 0001-Ignore-statuses-if-workflow-only-defines-identity-tr.patch
| app/controllers/workflows_controller.rb | ||
|---|---|---|
| 161 | 161 |
role_ids = Role.all.select(&:consider_workflow?).map(&:id) |
| 162 | 162 |
status_ids = WorkflowTransition.where( |
| 163 | 163 |
:tracker_id => @trackers.map(&:id), :role_id => role_ids |
| 164 |
).where( |
|
| 165 |
'old_status_id <> new_status_id' |
|
| 164 | 166 |
).distinct.pluck(:old_status_id, :new_status_id).flatten.uniq |
| 165 | 167 |
@statuses = IssueStatus.where(:id => status_ids).sorted.to_a.presence |
| 166 | 168 |
end |
| app/models/tracker.rb | ||
|---|---|---|
| 108 | 108 |
else |
| 109 | 109 |
@issue_status_ids ||= |
| 110 | 110 |
WorkflowTransition.where(:tracker_id => id). |
| 111 |
where('old_status_id <> new_status_id').
|
|
| 111 | 112 |
distinct.pluck(:old_status_id, :new_status_id).flatten.uniq |
| 112 | 113 |
end |
| 113 | 114 |
end |
| test/functional/workflows_controller_test.rb | ||
|---|---|---|
| 83 | 83 |
) |
| 84 | 84 |
end |
| 85 | 85 | |
| 86 |
def test_get_edit_with_role_and_tracker_should_not_include_only_identity_workflows |
|
| 87 |
WorkflowTransition.delete_all |
|
| 88 |
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 1) |
|
| 89 |
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 2, :new_status_id => 3) |
|
| 90 | ||
| 91 |
get :edit, :params => {:role_id => 1, :tracker_id => 1}
|
|
| 92 |
assert_response :success |
|
| 93 | ||
| 94 |
# statuses 1 and 5 not displayed |
|
| 95 |
statuses = IssueStatus.where(:id => [2, 3]).sorted.pluck(:name) |
|
| 96 |
assert_equal( |
|
| 97 |
["New issue"] + statuses, |
|
| 98 |
css_select('table.workflows.transitions-always tbody tr td:first').map(&:text).map(&:strip)
|
|
| 99 |
) |
|
| 100 |
end |
|
| 101 | ||
| 86 | 102 |
def test_get_edit_should_include_allowed_statuses_for_new_issues |
| 87 | 103 |
WorkflowTransition.delete_all |
| 88 | 104 |
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 0, :new_status_id => 1) |
| test/unit/tracker_test.rb | ||
|---|---|---|
| 89 | 89 |
def test_issue_statuses |
| 90 | 90 |
tracker = Tracker.find(1) |
| 91 | 91 |
WorkflowTransition.delete_all |
| 92 |
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 1) |
|
| 92 | 93 |
WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 2, :new_status_id => 3) |
| 93 | 94 |
WorkflowTransition.create!(:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 5) |
| 94 | 95 | |