]> source.dussan.org Git - redmine.git/commitdiff
Ignore statuses if workflow only defines identity transition (#37636).
authorGo MAEDA <maeda@farend.jp>
Sat, 17 Sep 2022 07:58:12 +0000 (07:58 +0000)
committerGo MAEDA <maeda@farend.jp>
Sat, 17 Sep 2022 07:58:12 +0000 (07:58 +0000)
Patch by Holger Just.

git-svn-id: https://svn.redmine.org/redmine/trunk@21818 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/workflows_controller.rb
app/models/tracker.rb
test/functional/workflows_controller_test.rb
test/unit/tracker_test.rb

index c0d5f865ea5e043c94e9e9005f4324b1da9069a3..3157ec6b36ab363c4d3024adf68f50c693da5714 100644 (file)
@@ -161,6 +161,8 @@ class WorkflowsController < ApplicationController
       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
index c5665054cdbf3125c7fe321b5d12ec7f83a403d2..fcc61222ff9ea81aa1b1413bd086906c50f9e6be 100644 (file)
@@ -108,6 +108,7 @@ class Tracker < ActiveRecord::Base
     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
index d086801ae87b29d80e971cb64058d1cf84dcaedb..05689090b7da5ffa0ef5c192e33fb79f5f67e0d4 100644 (file)
@@ -83,6 +83,22 @@ class WorkflowsControllerTest < Redmine::ControllerTest
     )
   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)
index f81aeb63b53253c10b2fb1c0809895a63c93a0a1..8eef06e587ab8cb3edb907d3dddbf1ff5684e9f6 100644 (file)
@@ -89,6 +89,7 @@ class TrackerTest < ActiveSupport::TestCase
   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)