diff --git a/app/services/workflows/bulk_update_service.rb b/app/services/workflows/bulk_update_service.rb index 4170cd18fc..ea75793592 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 eff2b58371..7194488545 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