dor-workflow-client 3.15.0 → 3.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 999836d9819299630a505d4f09ec8e8fd9a054fe8a7718b09096a7e3aae3b4cb
4
- data.tar.gz: 2aabfa8b7212d6b59a63b43c24b07d11d350ab25138b9888241a86d27a21282e
3
+ metadata.gz: 306ecf7474466434521965d8d0bf75496f019acb07802692967f49ee4eeb119b
4
+ data.tar.gz: 89f7a848c976cc332fa27b3cfdce8beb9819ead54f495f861e5155a03ac29263
5
5
  SHA512:
6
- metadata.gz: e79fc455a8757224ebc51ad4fb2c28d59801d0be5c7283cc393011ae374cb21ffb762bc52e21838317c4abb71b17ec79269c028aac0fc0dfcc425ecaaf7a904e
7
- data.tar.gz: ca91b5a46d08c5a2519d958d18ee55f0d201c13c6856b542a9ff0d5bef58ba80ff82e3c253fc5e323bbc3fac6ba866e99d7945b2392e682b92fb151d68d840d1
6
+ metadata.gz: 4969a4ada46d0bda079cd200d04e620cafcb7fcb03f3b847efb4ca342996518059eea623fd590270abdc97051e034881131193232ca980cc96262793d35b7900
7
+ data.tar.gz: e1d1a6b121d3511f21a56016fe641dbc31a5eee8f2e07617c5e7b3b04a36f419daaf0cf17500eabc1dff56b9f108666e339dee7f3d76fa81fde09afa725bc4b8
@@ -3,7 +3,7 @@
3
3
  module Dor
4
4
  module Workflow
5
5
  class Client
6
- VERSION = '3.15.0'
6
+ VERSION = '3.15.1'
7
7
  end
8
8
  end
9
9
  end
@@ -37,11 +37,7 @@ module Dor
37
37
  raise ArgumentError, 'wrong number of arguments, must be 1-3'
38
38
  end
39
39
 
40
- uri = "#{repo}/objects/#{druid}/versionClose"
41
- uri += '?' if !create_accession_wf || version
42
- uri += "version=#{version}" if version
43
- uri += 'create-accession=false' unless create_accession_wf
44
- requestor.request(uri, 'post', '')
40
+ requestor.request(construct_url(repo, druid, version, create_accession_wf), 'post', '')
45
41
  true
46
42
  end
47
43
  # rubocop:enable Metrics/MethodLength
@@ -49,6 +45,16 @@ module Dor
49
45
  private
50
46
 
51
47
  attr_reader :requestor
48
+
49
+ def construct_url(repo, druid, version, create_accession_wf)
50
+ url = "#{repo}/objects/#{druid}/versionClose"
51
+
52
+ qs_args = []
53
+ qs_args << "version=#{version}" if version
54
+ qs_args << 'create-accession=false' unless create_accession_wf
55
+ url += "?#{qs_args.join('&')}" unless qs_args.empty?
56
+ url
57
+ end
52
58
  end
53
59
  end
54
60
  end
@@ -19,6 +19,12 @@ module Dor
19
19
  end
20
20
  end
21
21
 
22
+ # @return [Array<String>] returns a list of errors for any process for the current version
23
+ def errors_for(version:)
24
+ ng_xml.xpath("//workflow/process[@version='#{version}' and @status='error']/@errorMessage")
25
+ .map(&:text)
26
+ end
27
+
22
28
  attr_reader :xml
23
29
 
24
30
  private
@@ -36,4 +36,27 @@ RSpec.describe Dor::Workflow::Response::Workflows do
36
36
  expect(subject.map(&:workflow_name)).to eq %w[assemblyWF sdrPreservationWF]
37
37
  end
38
38
  end
39
+
40
+ describe '#errors_for' do
41
+ subject { instance.errors_for(version: 2) }
42
+
43
+ let(:xml) do
44
+ <<~XML
45
+ <workflows objectId="druid:mw971zk1113">
46
+ <workflow repository="dor" objectId="druid:mw971zk1113" id="assemblyWF">
47
+ <process version="1" status="error" errorMessage="err1" />
48
+ <process version="2" status="error" errorMessage="err2" />
49
+ <process version="2" status="complete" errorMessage="err3" />
50
+ </workflow>
51
+ <workflow repository="dor" objectId="druid:mw971zk1113" id="sdrPreservationWF">
52
+ <process version="1" status="error" errorMessage="err4" />
53
+ <process version="2" status="error" errorMessage="err5" />
54
+ <process version="2" status="complete" errorMessage="err6" />
55
+ </workflow>
56
+ </workflows>
57
+ XML
58
+ end
59
+
60
+ it { is_expected.to eq %w[err2 err5] }
61
+ end
39
62
  end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Dor::Workflow::Client::VersionRoutes do
6
+ let(:mock_requestor) { instance_double(Dor::Workflow::Client::Requestor, request: nil) }
7
+
8
+ let(:routes) { described_class.new(requestor: mock_requestor) }
9
+
10
+ let(:repo) { 'dor' }
11
+
12
+ let(:druid) { 'druid:123' }
13
+
14
+ describe '#close_version' do
15
+ context 'with positional arguments' do
16
+ before do
17
+ allow(Deprecation).to receive(:warn)
18
+ end
19
+
20
+ it 'calls the versionClose endpoint with druid' do
21
+ routes.close_version(repo, druid)
22
+ expect(Deprecation).to have_received(:warn)
23
+ end
24
+
25
+ it 'optionally prevents creation of accessionWF' do
26
+ routes.close_version(repo, druid, false)
27
+ expect(mock_requestor).to have_received(:request)
28
+ .with('dor/objects/druid:123/versionClose?create-accession=false', 'post', '')
29
+ expect(Deprecation).to have_received(:warn)
30
+ end
31
+ end
32
+
33
+ context 'with kwargs' do
34
+ it 'calls the versionClose endpoint' do
35
+ routes.close_version(repo: repo, druid: druid)
36
+ expect(mock_requestor).to have_received(:request)
37
+ .with('dor/objects/druid:123/versionClose', 'post', '')
38
+ end
39
+
40
+ it 'optionally prevents creation of accessionWF' do
41
+ routes.close_version(repo: repo, druid: druid, create_accession_wf: false)
42
+ expect(mock_requestor).to have_received(:request)
43
+ .with('dor/objects/druid:123/versionClose?create-accession=false', 'post', '')
44
+ end
45
+
46
+ it 'optionally passes version' do
47
+ routes.close_version(repo: repo, druid: druid, version: 3)
48
+ expect(mock_requestor).to have_received(:request)
49
+ .with('dor/objects/druid:123/versionClose?version=3', 'post', '')
50
+ end
51
+
52
+ it 'optionally prevents creation of accessionWF and passes version' do
53
+ routes.close_version(repo: repo, druid: druid, create_accession_wf: false, version: 3)
54
+ expect(mock_requestor).to have_received(:request)
55
+ .with('dor/objects/druid:123/versionClose?version=3&create-accession=false', 'post', '')
56
+ end
57
+ end
58
+ end
59
+ end
@@ -742,55 +742,6 @@ RSpec.describe Dor::Workflow::Client do
742
742
  end
743
743
  end
744
744
 
745
- describe '#close_version' do
746
- let(:stubs) do
747
- Faraday::Adapter::Test::Stubs.new do |stub|
748
- stub.post('dor/objects/druid:123/versionClose?create-accession=false') do |_env|
749
- [202, {}, '']
750
- end
751
-
752
- stub.post('dor/objects/druid:123/versionClose') do |_env|
753
- [202, {}, '']
754
- end
755
- end
756
- end
757
-
758
- let(:url) { 'dor/objects/druid:123/versionClose' }
759
-
760
- context 'with positional arguments' do
761
- before do
762
- allow(Deprecation).to receive(:warn)
763
- end
764
-
765
- it 'calls the versionClose endpoint with druid' do
766
- client.close_version(@repo, @druid)
767
- expect(Deprecation).to have_received(:warn)
768
- end
769
-
770
- it 'optionally prevents creation of accessionWF' do
771
- expect(mock_http_connection).to receive(:post).with('dor/objects/druid:123/versionClose?create-accession=false').and_call_original
772
- client.close_version(@repo, @druid, false)
773
- expect(Deprecation).to have_received(:warn)
774
- end
775
- end
776
-
777
- context 'with kwargs' do
778
- it 'calls the versionClose endpoint with druid' do
779
- client.close_version(repo: @repo, druid: @druid)
780
- end
781
-
782
- it 'optionally prevents creation of accessionWF' do
783
- expect(mock_http_connection).to receive(:post).with('dor/objects/druid:123/versionClose?create-accession=false').and_call_original
784
- client.close_version(repo: @repo, druid: @druid, create_accession_wf: false)
785
- end
786
-
787
- it 'optionally passes version' do
788
- expect(mock_http_connection).to receive(:post).with('dor/objects/druid:123/versionClose?version=3').and_call_original
789
- client.close_version(repo: @repo, druid: @druid, version: 3)
790
- end
791
- end
792
- end
793
-
794
745
  describe '.stale_queued_workflows' do
795
746
  let(:stubs) do
796
747
  Faraday::Adapter::Test::Stubs.new do |stub|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dor-workflow-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.15.0
4
+ version: 3.15.1
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: 2020-01-08 00:00:00.000000000 Z
12
+ date: 2020-01-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -231,6 +231,7 @@ files:
231
231
  - spec/workflow/client/connection_factory_spec.rb
232
232
  - spec/workflow/client/lifecycle_routes_spec.rb
233
233
  - spec/workflow/client/requestor_spec.rb
234
+ - spec/workflow/client/version_routes_spec.rb
234
235
  - spec/workflow/client/workflow_routes_spec.rb
235
236
  - spec/workflow/client/workflow_template_spec.rb
236
237
  - spec/workflow/client_spec.rb
@@ -252,7 +253,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
252
253
  - !ruby/object:Gem::Version
253
254
  version: '0'
254
255
  requirements: []
255
- rubygems_version: 3.0.3
256
+ rubygems_version: 3.1.2
256
257
  signing_key:
257
258
  specification_version: 4
258
259
  summary: Provides convenience methods to work with the DOR Workflow Service
@@ -264,6 +265,7 @@ test_files:
264
265
  - spec/workflow/client/connection_factory_spec.rb
265
266
  - spec/workflow/client/lifecycle_routes_spec.rb
266
267
  - spec/workflow/client/requestor_spec.rb
268
+ - spec/workflow/client/version_routes_spec.rb
267
269
  - spec/workflow/client/workflow_routes_spec.rb
268
270
  - spec/workflow/client/workflow_template_spec.rb
269
271
  - spec/workflow/client_spec.rb