Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

fix unsetting all workflows

ulfertsdca1c3fb58c4
diff --git a/app/services/workflows/bulk_update_service.rb b/app/services/workflows/bulk_update_service.rb
index 4170cd18fcd..ea75793592e 100644
--- a/app/services/workflows/bulk_update_service.rb
+++ b/app/services/workflows/bulk_update_service.rb
@@ -58,7 +58,7 @@ class Workflows::BulkUpdateService < ::BaseServices::Update
def build_workflows(status_transitions)
new_workflows = []
- status_transitions.each do |status_id, transitions|
+ (status_transitions || {}).each do |status_id, transitions|
transitions.each do |new_status_id, options|
new_workflows << Workflow.new(type: type,
role: role,
diff --git a/spec/services/workflows/bulk_update_service_integration_spec.rb b/spec/services/workflows/bulk_update_service_integration_spec.rb
index eff2b583719..71944885456 100644
--- a/spec/services/workflows/bulk_update_service_integration_spec.rb
+++ b/spec/services/workflows/bulk_update_service_integration_spec.rb
@@ -125,5 +125,22 @@ describe Workflows::BulkUpdateService, 'integration', type: :model do
.to eql 0
end
end
+
+ context 'with no params' do
+ let(:params) do
+ nil
+ end
+
+ before do
+ Workflow.create!(role_id: role.id, type_id: type.id, old_status_id: status3.id, new_status_id: status2.id)
+ end
+
+ it 'should clear all workflows' do
+ subject
+
+ expect(Workflow.where(type_id: type.id, role_id: role.id).count)
+ .to eql 0
+ end
+ end
end
end