diff --git a/app/services/workflow_state_service.rb b/app/services/workflow_state_service.rb index 1651f5974..310f662b0 100644 --- a/app/services/workflow_state_service.rb +++ b/app/services/workflow_state_service.rb @@ -29,7 +29,7 @@ def open? return !accessioning? && !accessioned? if version == 1 # Otherwise, is there an active versionWF? - active_version_wf? + active_workflow?(workflow: 'versioningWF') end # The following methods were extracted from VersionService. diff --git a/spec/services/workflow_state_service_spec.rb b/spec/services/workflow_state_service_spec.rb index b417d33b5..9de73740b 100644 --- a/spec/services/workflow_state_service_spec.rb +++ b/spec/services/workflow_state_service_spec.rb @@ -76,21 +76,25 @@ context 'when > version 1 and there is an active versionWF' do let(:version) { 2 } + let(:workflow_response) { instance_double(Dor::Workflow::Response::Workflow, active_for?: true, complete_for?: false) } + before do - allow(workflow_client).to receive(:active_lifecycle).and_return(Time.current) + allow(workflow_client).to receive(:workflow).and_return(workflow_response) end it 'returns true' do expect(service.open?).to be true - expect(workflow_client).to have_received(:active_lifecycle).with(druid:, milestone_name: 'opened', version: '2') + expect(workflow_client).to have_received(:workflow).with(pid: druid, workflow_name: 'versioningWF') end end context 'when > version 1 and there is not an active versionWF' do let(:version) { 2 } + let(:workflow_response) { instance_double(Dor::Workflow::Response::Workflow, active_for?: true, complete_for?: true) } + before do - allow(workflow_client).to receive(:active_lifecycle).and_return(nil) + allow(workflow_client).to receive(:workflow).and_return(workflow_response) end it 'returns false' do