fix unsetting all workflows

pull/7839/head
ulferts 5 years ago
parent 3e24089b71
commit dca1c3fb58
No known key found for this signature in database
GPG Key ID: A205708DE1284017
  1. 2
      app/services/workflows/bulk_update_service.rb
  2. 17
      spec/services/workflows/bulk_update_service_integration_spec.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,

@ -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

Loading…
Cancel
Save