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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 247315ca28af42d73ab1947353b8ae71f459d75b
4
- data.tar.gz: 0204c4ba989f633559264556415dfbc85db0a16e
2
+ SHA256:
3
+ metadata.gz: ffae9b6a6c8ad9f6b160c80230c85f97387d9cd96c64ee3954c9c28c5f6d83b8
4
+ data.tar.gz: b682177ac31b9658cf850721ebcab413fb59ff5d9ab396540e22831330f02eec
5
5
  SHA512:
6
- metadata.gz: '09781481dd5d29f0fe06a16e015587a0b8296cc3ab27b36e67f4ce5f0451eb27f477dea6a3af5621ca5bf3449e62fca5017354a4e8268c4eb9693bd41a6f68e3'
7
- data.tar.gz: 5d08832b83c3e2996996e691664f89bbbce47e521ec36e7b4dbb2482345a3cc83395d9592d77116f9ec3b57bef85ac7ce2e2675d2a75bd4865ad18ea0d009d72
6
+ metadata.gz: f1c55e5f176a70ba9201e69211a732a7447a1484374df55b9bbcb1113215da2f5c4936fbe966ec08f83f58e7ad34b4a4b9e97fc0b24bdee3cfdde15fc9152896
7
+ data.tar.gz: 903f5def9d9c11e753600bec6fbe40cfe31396887739cfc4ee1b8a8bf65b1eddfe74ca47f5930d6a8f39de060841c801cc1a333eb6e41adb8f5df0aaf6bf2a34
@@ -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.2.5
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.7.1"
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
- Provides Ruby convenience methods to work with the DOR Workflow REST Service. The REST API is defined here:
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
- status = doc.root.at_xpath("//process[@name='#{process}']/@status")
100
- status = status.content if status
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}/#{uri_string}"
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
@@ -1,7 +1,7 @@
1
1
  module Dor
2
2
  module Workflow
3
3
  module Service
4
- VERSION = '2.3.0'
4
+ VERSION = '2.4.0'
5
5
  end
6
6
  end
7
7
  end
@@ -6,6 +6,7 @@ SimpleCov.start do
6
6
  add_filter 'spec'
7
7
  end
8
8
 
9
+ require 'byebug'
9
10
  require 'dor-workflow-service'
10
11
  require 'equivalent-xml'
11
12
  require 'equivalent-xml/rspec_matchers'
@@ -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("#{@repo}/objects/#{@druid}/workflows/etdSubmitWF") do |env|
172
- [200, {}, '<process name="registrar-approval" status="completed" />']
173
+ stub.get("#{repo}/objects/#{druid}/workflows/#{workflow_name}") do |env|
174
+ response
173
175
  end
176
+ end
177
+ end
174
178
 
175
- stub.get("#{@repo}/objects/#{@druid}/workflows/missingWF") do |env|
176
- [404, {}, '']
177
- end
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
- stub.get("#{@repo}/objects/#{@druid}/workflows/errorWF") do |env|
180
- [200, {}, 'something not xml']
181
- end
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
- stub.get("#{@repo}/objects/#{@druid}/workflows/accessionWF") do |env|
184
- [200, {}, '<process name="registrar-approval" status="completed" />']
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
- it 'parses workflow xml and returns status as a string' do
190
- expect(Dor::WorkflowService.get_workflow_status('dor', 'druid:123', 'etdSubmitWF', 'registrar-approval')).to eq('completed')
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
- it 'should throw an exception if it fails for any reason' do
193
- expect{ Dor::WorkflowService.get_workflow_status('dor', 'druid:123', 'missingWF', 'registrar-approval') }.to raise_error Dor::WorkflowException
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
- it 'should throw an exception if it cannot parse the response' do
196
- expect{ Dor::WorkflowService.get_workflow_status('dor', 'druid:123', 'errorWF', 'registrar-approval') }.to raise_error(Dor::WorkflowException, "Unable to parse response:\nsomething not xml")
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
- it 'should return nil if the workflow/process combination doesnt exist' do
199
- expect(Dor::WorkflowService.get_workflow_status('dor', 'druid:123', 'accessionWF', 'publish')).to be_nil
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.3.0
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: 2018-04-13 00:00:00.000000000 Z
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.13
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