Skip to content

Commit

Permalink
Fix WorkflowStateService.open?
Browse files Browse the repository at this point in the history
closes #4820
  • Loading branch information
justinlittman committed Apr 9, 2024
1 parent 6e357ae commit 576d72c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/services/workflow_state_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 7 additions & 3 deletions spec/services/workflow_state_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 576d72c

Please sign in to comment.