dor-workflow-service 2.3.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +2 -9
- data/README.md +1 -2
- data/lib/dor/services/workflow_service.rb +4 -4
- data/lib/dor/workflow_version.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/workflow_service_spec.rb +55 -19
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ffae9b6a6c8ad9f6b160c80230c85f97387d9cd96c64ee3954c9c28c5f6d83b8
|
4
|
+
data.tar.gz: b682177ac31b9658cf850721ebcab413fb59ff5d9ab396540e22831330f02eec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1c55e5f176a70ba9201e69211a732a7447a1484374df55b9bbcb1113215da2f5c4936fbe966ec08f83f58e7ad34b4a4b9e97fc0b24bdee3cfdde15fc9152896
|
7
|
+
data.tar.gz: 903f5def9d9c11e753600bec6fbe40cfe31396887739cfc4ee1b8a8bf65b1eddfe74ca47f5930d6a8f39de060841c801cc1a333eb6e41adb8f5df0aaf6bf2a34
|
data/.travis.yml
CHANGED
@@ -1,17 +1,10 @@
|
|
1
1
|
language: ruby
|
2
|
-
sudo: false
|
3
2
|
notifications:
|
4
3
|
email: false
|
5
4
|
|
6
5
|
rvm:
|
7
|
-
- 2.
|
8
|
-
- 2.3.1
|
9
|
-
|
10
|
-
matrix:
|
11
|
-
include:
|
12
|
-
- rvm: 2.1.2
|
13
|
-
env: RAILS_VERSION=4.2.7.1
|
6
|
+
- 2.5.3
|
14
7
|
|
15
8
|
env:
|
16
|
-
- "RAILS_VERSION=4.2.
|
9
|
+
- "RAILS_VERSION=4.2.10"
|
17
10
|
- "RAILS_VERSION=5.0.0.1"
|
data/README.md
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
[![Build Status](https://travis-ci.org/sul-dlss/dor-workflow-service.svg?branch=master)](https://travis-ci.org/sul-dlss/dor-workflow-service)
|
2
|
-
[![Dependency Status](https://gemnasium.com/sul-dlss/dor-workflow-service.svg)](https://gemnasium.com/sul-dlss/dor-workflow-service)
|
3
2
|
|
4
3
|
# dor-workflow-service gem
|
5
4
|
|
6
|
-
|
5
|
+
A Ruby client to work with the DOR Workflow REST Service. The REST API is defined here:
|
7
6
|
https://consul.stanford.edu/display/DOR/DOR+services#DORservices-initializeworkflow
|
8
7
|
|
9
8
|
## Usage
|
@@ -96,9 +96,9 @@ module Dor
|
|
96
96
|
workflow_md = get_workflow_xml(repo, druid, workflow)
|
97
97
|
doc = Nokogiri::XML(workflow_md)
|
98
98
|
raise Dor::WorkflowException.new("Unable to parse response:\n#{workflow_md}") if doc.root.nil?
|
99
|
-
|
100
|
-
|
101
|
-
status
|
99
|
+
processes = doc.root.xpath("//process[@name='#{process}']")
|
100
|
+
process = processes.max { |a, b| a.attr('version').to_i <=> b.attr('version').to_i }
|
101
|
+
process&.attr('status')
|
102
102
|
end
|
103
103
|
|
104
104
|
#
|
@@ -555,7 +555,7 @@ module Dor
|
|
555
555
|
response.body
|
556
556
|
end
|
557
557
|
rescue *workflow_service_exceptions_to_catch => e
|
558
|
-
msg = "Failed to retrieve resource: #{meth} #{base_url}
|
558
|
+
msg = "Failed to retrieve resource: #{meth} #{base_url}#{uri_string}"
|
559
559
|
msg += " (HTTP status #{e.response[:status]})" if e.respond_to?(:response) && e.response
|
560
560
|
raise Dor::WorkflowException, msg
|
561
561
|
end
|
data/lib/dor/workflow_version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -166,37 +166,73 @@ describe Dor::WorkflowService do
|
|
166
166
|
end
|
167
167
|
|
168
168
|
describe '#get_workflow_status' do
|
169
|
+
let(:repo) { @repo }
|
170
|
+
let(:druid) { @druid }
|
169
171
|
let(:stubs) do
|
170
172
|
Faraday::Adapter::Test::Stubs.new do |stub|
|
171
|
-
stub.get("#{
|
172
|
-
|
173
|
+
stub.get("#{repo}/objects/#{druid}/workflows/#{workflow_name}") do |env|
|
174
|
+
response
|
173
175
|
end
|
176
|
+
end
|
177
|
+
end
|
174
178
|
|
175
|
-
|
176
|
-
|
177
|
-
|
179
|
+
subject { Dor::WorkflowService.get_workflow_status(repo, druid, workflow_name, step_name) }
|
180
|
+
let(:step_name) { 'registrar-approval' }
|
181
|
+
let(:workflow_name) { 'etdSubmitWF' }
|
182
|
+
let(:status) { 200 }
|
183
|
+
let(:response) do
|
184
|
+
[status, {}, xml]
|
185
|
+
end
|
186
|
+
let(:xml) { '' }
|
178
187
|
|
179
|
-
|
180
|
-
|
181
|
-
|
188
|
+
context 'when a single result is returned' do
|
189
|
+
let(:xml) do
|
190
|
+
'<workflow><process name="registrar-approval" status="completed" /></workflow>'
|
191
|
+
end
|
182
192
|
|
183
|
-
|
184
|
-
|
185
|
-
end
|
193
|
+
it 'returns status as a string' do
|
194
|
+
expect(subject).to eq('completed')
|
186
195
|
end
|
187
196
|
end
|
188
197
|
|
189
|
-
|
190
|
-
|
198
|
+
context 'when a multiple versions are returned' do
|
199
|
+
let(:xml) do
|
200
|
+
'<workflow><process name="registrar-approval" version="1" status="completed" />
|
201
|
+
<process name="registrar-approval" version="2" status="waiting" /></workflow>'
|
202
|
+
end
|
203
|
+
|
204
|
+
it 'returns the status for the highest version' do
|
205
|
+
expect(subject).to eq('waiting')
|
206
|
+
end
|
191
207
|
end
|
192
|
-
|
193
|
-
|
208
|
+
|
209
|
+
context 'when it fails for any reason' do
|
210
|
+
let(:status) { 404 }
|
211
|
+
|
212
|
+
it 'throws an exception' do
|
213
|
+
expect{ subject }.to raise_error Dor::WorkflowException
|
214
|
+
end
|
194
215
|
end
|
195
|
-
|
196
|
-
|
216
|
+
|
217
|
+
context 'when it cannot parse the response' do
|
218
|
+
let(:xml) do
|
219
|
+
'something not xml'
|
220
|
+
end
|
221
|
+
|
222
|
+
it 'throws an exception' do
|
223
|
+
expect{ subject }.to raise_error Dor::WorkflowException, "Unable to parse response:\nsomething not xml"
|
224
|
+
end
|
197
225
|
end
|
198
|
-
|
199
|
-
|
226
|
+
|
227
|
+
context 'when the workflow/process combination doesnt exist' do
|
228
|
+
let(:xml) do
|
229
|
+
'<workflow><process name="registrar-approval" status="completed" /></workflow>'
|
230
|
+
end
|
231
|
+
let(:step_name) { 'publish' }
|
232
|
+
|
233
|
+
it 'returns nil' do
|
234
|
+
expect(subject).to be_nil
|
235
|
+
end
|
200
236
|
end
|
201
237
|
end
|
202
238
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dor-workflow-service
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Willy Mene
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2019-01-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -255,7 +255,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
255
255
|
version: '0'
|
256
256
|
requirements: []
|
257
257
|
rubyforge_project:
|
258
|
-
rubygems_version: 2.6
|
258
|
+
rubygems_version: 2.7.6
|
259
259
|
signing_key:
|
260
260
|
specification_version: 4
|
261
261
|
summary: Provides convenience methods to work with the DOR Workflow Service
|