dor-workflow-client 3.24.0 → 5.0.0
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 +4 -4
- data/.circleci/config.yml +8 -33
- data/.github/pull_request_template.md +3 -5
- data/.gitignore +0 -2
- data/.rubocop.yml +105 -2
- data/.rubocop_todo.yml +42 -9
- data/Gemfile +1 -0
- data/Gemfile.lock +122 -0
- data/README.md +1 -1
- data/dor-workflow-client.gemspec +9 -5
- data/lib/dor/workflow/client/connection_factory.rb +3 -8
- data/lib/dor/workflow/client/lifecycle_routes.rb +4 -71
- data/lib/dor/workflow/client/queues.rb +13 -46
- data/lib/dor/workflow/client/status.rb +0 -2
- data/lib/dor/workflow/client/version.rb +1 -1
- data/lib/dor/workflow/client/version_routes.rb +1 -23
- data/lib/dor/workflow/client/workflow_routes.rb +11 -149
- data/lib/dor/workflow/client.rb +2 -2
- data/lib/dor/workflow/response/process.rb +1 -2
- data/lib/dor/workflow/response/workflow.rb +1 -9
- data/spec/models/response/process_spec.rb +0 -17
- data/spec/models/response/workflow_spec.rb +1 -17
- data/spec/workflow/client/lifecycle_routes_spec.rb +18 -152
- data/spec/workflow/client/version_routes_spec.rb +1 -44
- data/spec/workflow/client/workflow_routes_spec.rb +13 -0
- data/spec/workflow/client_spec.rb +9 -258
- metadata +51 -39
@@ -17,177 +17,43 @@ RSpec.describe Dor::Workflow::Client::LifecycleRoutes do
|
|
17
17
|
|
18
18
|
before do
|
19
19
|
allow(routes).to receive(:query_lifecycle).and_return(ng_xml)
|
20
|
-
allow(Deprecation).to receive(:warn)
|
21
20
|
end
|
22
21
|
|
23
|
-
|
24
|
-
subject(:milestones) { routes.milestones(repo, druid) }
|
22
|
+
subject(:milestones) { routes.milestones(druid: druid) }
|
25
23
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
expect(Deprecation).to have_received(:warn).twice
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'with kwargs' do
|
34
|
-
subject(:milestones) { routes.milestones(druid: druid) }
|
35
|
-
|
36
|
-
it 'includes the version in with the milestones' do
|
37
|
-
expect(milestones.first[:milestone]).to eq('published')
|
38
|
-
expect(milestones.first[:version]).to eq('2')
|
39
|
-
end
|
24
|
+
it 'includes the version in with the milestones' do
|
25
|
+
expect(milestones.first[:milestone]).to eq('published')
|
26
|
+
expect(milestones.first[:version]).to eq('2')
|
40
27
|
end
|
41
28
|
end
|
42
29
|
|
43
30
|
describe '#lifecycle' do
|
44
|
-
context '
|
45
|
-
|
46
|
-
allow(Deprecation).to receive(:warn)
|
47
|
-
end
|
48
|
-
|
49
|
-
context 'without version' do
|
50
|
-
subject(:lifecycle) { routes.lifecycle(repo, druid, 'submitted') }
|
51
|
-
|
52
|
-
it 'make the request' do
|
53
|
-
lifecycle
|
54
|
-
expect(requestor).to have_received(:request).with('objects/druid:gv054hp4128/lifecycle')
|
55
|
-
expect(Deprecation).to have_received(:warn).twice
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context 'with version' do
|
60
|
-
subject(:lifecycle) { routes.lifecycle(repo, druid, 'submitted', version: 3) }
|
31
|
+
context 'without version' do
|
32
|
+
subject(:lifecycle) { routes.lifecycle(druid: druid, milestone_name: 'submitted') }
|
61
33
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
expect(Deprecation).to have_received(:warn).twice
|
66
|
-
end
|
34
|
+
it 'make the request' do
|
35
|
+
lifecycle
|
36
|
+
expect(requestor).to have_received(:request).with('objects/druid:gv054hp4128/lifecycle')
|
67
37
|
end
|
68
38
|
end
|
69
39
|
|
70
|
-
context 'with
|
71
|
-
|
72
|
-
allow(Deprecation).to receive(:warn)
|
73
|
-
end
|
74
|
-
|
75
|
-
context 'with deprecated repo arg' do
|
76
|
-
context 'without version' do
|
77
|
-
subject(:lifecycle) { routes.lifecycle(repo: repo, druid: druid, milestone_name: 'submitted') }
|
78
|
-
|
79
|
-
it 'make the request' do
|
80
|
-
lifecycle
|
81
|
-
expect(requestor).to have_received(:request).with('objects/druid:gv054hp4128/lifecycle')
|
82
|
-
expect(Deprecation).to have_received(:warn)
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
context 'with version' do
|
87
|
-
subject(:lifecycle) { routes.lifecycle(repo: repo, druid: druid, milestone_name: 'submitted', version: 3) }
|
40
|
+
context 'with version' do
|
41
|
+
subject(:lifecycle) { routes.lifecycle(druid: druid, milestone_name: 'submitted', version: 3) }
|
88
42
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
expect(Deprecation).to have_received(:warn)
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
context 'without version' do
|
98
|
-
subject(:lifecycle) { routes.lifecycle(druid: druid, milestone_name: 'submitted') }
|
99
|
-
|
100
|
-
it 'make the request' do
|
101
|
-
lifecycle
|
102
|
-
expect(requestor).to have_received(:request).with('objects/druid:gv054hp4128/lifecycle')
|
103
|
-
expect(Deprecation).not_to have_received(:warn)
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
context 'with version' do
|
108
|
-
subject(:lifecycle) { routes.lifecycle(druid: druid, milestone_name: 'submitted', version: 3) }
|
109
|
-
|
110
|
-
it 'makes the request with the version' do
|
111
|
-
lifecycle
|
112
|
-
expect(requestor).to have_received(:request).with('objects/druid:gv054hp4128/lifecycle?version=3')
|
113
|
-
expect(Deprecation).not_to have_received(:warn)
|
114
|
-
end
|
43
|
+
it 'makes the request with the version' do
|
44
|
+
lifecycle
|
45
|
+
expect(requestor).to have_received(:request).with('objects/druid:gv054hp4128/lifecycle?version=3')
|
115
46
|
end
|
116
47
|
end
|
117
48
|
end
|
118
49
|
|
119
50
|
describe '#active_lifecycle' do
|
120
|
-
context 'with positional arguments' do
|
121
|
-
before do
|
122
|
-
allow(Deprecation).to receive(:warn)
|
123
|
-
end
|
124
|
-
|
125
|
-
context 'without version' do
|
126
|
-
subject(:active_lifecycle) { routes.active_lifecycle(repo, druid, 'submitted') }
|
127
|
-
|
128
|
-
it 'make the request' do
|
129
|
-
active_lifecycle
|
130
|
-
expect(requestor).to have_received(:request).with('objects/druid:gv054hp4128/lifecycle?active-only=true')
|
131
|
-
expect(Deprecation).to have_received(:warn).twice
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
context 'with version' do
|
136
|
-
subject(:active_lifecycle) { routes.active_lifecycle(repo, druid, 'submitted', version: 3) }
|
137
|
-
|
138
|
-
it 'makes the request with the version' do
|
139
|
-
active_lifecycle
|
140
|
-
expect(requestor).to have_received(:request).with('objects/druid:gv054hp4128/lifecycle?version=3&active-only=true')
|
141
|
-
expect(Deprecation).to have_received(:warn).twice
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
51
|
context 'with kwargs' do
|
147
|
-
|
148
|
-
allow(Deprecation).to receive(:warn)
|
149
|
-
end
|
150
|
-
|
151
|
-
context 'with deprecated repo arg' do
|
152
|
-
context 'without version' do
|
153
|
-
subject(:active_lifecycle) { routes.active_lifecycle(repo: repo, druid: druid, milestone_name: 'submitted') }
|
154
|
-
|
155
|
-
it 'make the request' do
|
156
|
-
active_lifecycle
|
157
|
-
expect(requestor).to have_received(:request).with('objects/druid:gv054hp4128/lifecycle?active-only=true')
|
158
|
-
expect(Deprecation).to have_received(:warn)
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
context 'with version' do
|
163
|
-
subject(:active_lifecycle) { routes.active_lifecycle(repo: repo, druid: druid, milestone_name: 'submitted', version: 3) }
|
164
|
-
|
165
|
-
it 'makes the request with the version' do
|
166
|
-
active_lifecycle
|
167
|
-
expect(requestor).to have_received(:request).with('objects/druid:gv054hp4128/lifecycle?version=3&active-only=true')
|
168
|
-
expect(Deprecation).to have_received(:warn)
|
169
|
-
end
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
context 'without version' do
|
174
|
-
subject(:active_lifecycle) { routes.active_lifecycle(druid: druid, milestone_name: 'submitted') }
|
175
|
-
|
176
|
-
it 'make the request' do
|
177
|
-
active_lifecycle
|
178
|
-
expect(requestor).to have_received(:request).with('objects/druid:gv054hp4128/lifecycle?active-only=true')
|
179
|
-
expect(Deprecation).not_to have_received(:warn)
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
context 'with version' do
|
184
|
-
subject(:active_lifecycle) { routes.active_lifecycle(druid: druid, milestone_name: 'submitted', version: 3) }
|
52
|
+
subject(:active_lifecycle) { routes.active_lifecycle(druid: druid, milestone_name: 'submitted', version: 3) }
|
185
53
|
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
expect(Deprecation).not_to have_received(:warn)
|
190
|
-
end
|
54
|
+
it 'makes the request with the version' do
|
55
|
+
active_lifecycle
|
56
|
+
expect(requestor).to have_received(:request).with('objects/druid:gv054hp4128/lifecycle?version=3&active-only=true')
|
191
57
|
end
|
192
58
|
end
|
193
59
|
end
|
@@ -12,51 +12,8 @@ RSpec.describe Dor::Workflow::Client::VersionRoutes do
|
|
12
12
|
let(:druid) { 'druid:123' }
|
13
13
|
|
14
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).twice
|
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('objects/druid:123/versionClose?create-accession=false', 'post', '')
|
29
|
-
expect(Deprecation).to have_received(:warn).twice
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
15
|
context 'with kwargs' do
|
34
|
-
it '
|
35
|
-
routes.close_version(druid: druid)
|
36
|
-
expect(mock_requestor).to have_received(:request)
|
37
|
-
.with('objects/druid:123/versionClose', 'post', '')
|
38
|
-
end
|
39
|
-
|
40
|
-
context 'with deprecated repo arg' do
|
41
|
-
before do
|
42
|
-
allow(Deprecation).to receive(:warn)
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'calls the versionClose endpoint' do
|
46
|
-
routes.close_version(repo: repo, druid: druid)
|
47
|
-
expect(mock_requestor).to have_received(:request)
|
48
|
-
.with('objects/druid:123/versionClose', 'post', '')
|
49
|
-
expect(Deprecation).to have_received(:warn)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'optionally prevents creation of accessionWF' do
|
54
|
-
routes.close_version(druid: druid, create_accession_wf: false)
|
55
|
-
expect(mock_requestor).to have_received(:request)
|
56
|
-
.with('objects/druid:123/versionClose?create-accession=false', 'post', '')
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'optionally passes version' do
|
16
|
+
it 'passes version' do
|
60
17
|
routes.close_version(druid: druid, version: 3)
|
61
18
|
expect(mock_requestor).to have_received(:request)
|
62
19
|
.with('objects/druid:123/versionClose?version=3', 'post', '')
|
@@ -147,6 +147,19 @@ RSpec.describe Dor::Workflow::Client::WorkflowRoutes do
|
|
147
147
|
end
|
148
148
|
end
|
149
149
|
|
150
|
+
describe '#delete_all_workflows' do
|
151
|
+
subject(:delete_all_workflows) do
|
152
|
+
routes.delete_all_workflows(pid: 'druid:mw971zk1113')
|
153
|
+
end
|
154
|
+
let(:mock_requestor) { instance_double(Dor::Workflow::Client::Requestor, request: nil) }
|
155
|
+
|
156
|
+
it 'sends a delete request' do
|
157
|
+
delete_all_workflows
|
158
|
+
expect(mock_requestor).to have_received(:request)
|
159
|
+
.with('objects/druid:mw971zk1113/workflows', 'delete')
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
150
163
|
describe '#all_workflows' do
|
151
164
|
let(:xml) do
|
152
165
|
<<~XML
|
@@ -68,50 +68,7 @@ RSpec.describe Dor::Workflow::Client do
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
describe '#create_workflow' do
|
72
|
-
let(:stubs) do
|
73
|
-
Faraday::Adapter::Test::Stubs.new do |stub|
|
74
|
-
stub.post("objects/#{@druid}/workflows/etdSubmitWF") { |_env| [201, {}, ''] }
|
75
|
-
stub.post("objects/#{@druid}/workflows/raiseException") { |_env| raise 'broken' }
|
76
|
-
stub.post("objects/#{@druid}/workflows/laneIdWF?lane-id=foo_lane") { |_env| [201, {}, ''] }
|
77
|
-
stub.post("objects/#{@druid}/workflows/versionWF?version=2") { |_env| [201, {}, ''] }
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
before do
|
82
|
-
allow(Deprecation).to receive(:warn)
|
83
|
-
end
|
84
|
-
|
85
|
-
it 'requests the workflow by name and return the URL to the workflow' do
|
86
|
-
client.create_workflow(nil, @druid, 'etdSubmitWF', wf_xml)
|
87
|
-
expect(Deprecation).to have_received(:warn).twice
|
88
|
-
end
|
89
|
-
|
90
|
-
it 'raises on an unexpected Exception' do
|
91
|
-
expect { client.create_workflow(nil, @druid, 'raiseException', wf_xml) }.to raise_error(Exception, 'broken')
|
92
|
-
expect(Deprecation).to have_received(:warn).twice
|
93
|
-
end
|
94
|
-
|
95
|
-
it 'sets the lane_id param if provided in options hash' do
|
96
|
-
client.create_workflow(nil, @druid, 'laneIdWF', wf_xml, lane_id: 'foo_lane')
|
97
|
-
expect(Deprecation).to have_received(:warn).twice
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
71
|
describe '#create_workflow_by_name' do
|
102
|
-
context 'with no args' do
|
103
|
-
let(:stubs) do
|
104
|
-
Faraday::Adapter::Test::Stubs.new do |stub|
|
105
|
-
stub.post("objects/#{@druid}/workflows/etdSubmitWF") { |_env| [201, {}, ''] }
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
it 'requests the workflow by name and return the URL to the workflow' do
|
110
|
-
expect(Deprecation).to receive(:warn)
|
111
|
-
client.create_workflow_by_name(@druid, 'etdSubmitWF')
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
72
|
context 'when an unexpected exception is raised' do
|
116
73
|
let(:stubs) do
|
117
74
|
Faraday::Adapter::Test::Stubs.new do |stub|
|
@@ -149,72 +106,6 @@ RSpec.describe Dor::Workflow::Client do
|
|
149
106
|
end
|
150
107
|
end
|
151
108
|
|
152
|
-
describe '#update_workflow_status' do
|
153
|
-
let(:stubs) do
|
154
|
-
Faraday::Adapter::Test::Stubs.new do |stub|
|
155
|
-
stub.put("objects/#{@druid}/workflows/etdSubmitWF/registrar-approval?current-status=queued") do |_env|
|
156
|
-
[201, {}, '{"next_steps":["submit-marc"]}']
|
157
|
-
end
|
158
|
-
|
159
|
-
stub.put("objects/#{@druid}/workflows/etdSubmitWF/registrar-approval") do |env|
|
160
|
-
expect(env.body).to eq "<?xml version=\"1.0\"?>\n<process name=\"registrar-approval\" status=\"completed\" elapsed=\"0\" note=\"annotation\" version=\"2\" laneId=\"lane2\"/>\n"
|
161
|
-
[201, {}, '{"next_steps":["submit-marc"]}']
|
162
|
-
end
|
163
|
-
|
164
|
-
stub.put("objects/#{@druid}/workflows/errorWF/registrar-approval") do |_env|
|
165
|
-
[400, {}, '']
|
166
|
-
end
|
167
|
-
end
|
168
|
-
end
|
169
|
-
before do
|
170
|
-
allow(Deprecation).to receive(:warn)
|
171
|
-
end
|
172
|
-
|
173
|
-
it 'should update workflow status and return true if successful' do
|
174
|
-
expect(client.update_workflow_status(nil, @druid, 'etdSubmitWF', 'registrar-approval', 'completed', version: 2, note: 'annotation', lane_id: 'lane2')).to be_kind_of Dor::Workflow::Response::Update
|
175
|
-
end
|
176
|
-
|
177
|
-
it 'should return false if the PUT to the DOR workflow service throws an exception' do
|
178
|
-
expect { client.update_workflow_status(nil, @druid, 'errorWF', 'registrar-approval', 'completed') }.to raise_error(Dor::WorkflowException, /status 400/)
|
179
|
-
end
|
180
|
-
|
181
|
-
it 'performs a conditional update when current-status is passed as a parameter' do
|
182
|
-
expect(mock_http_connection).to receive(:put).with("/objects/#{@druid}/workflows/etdSubmitWF/registrar-approval?current-status=queued").and_call_original
|
183
|
-
|
184
|
-
expect(client.update_workflow_status(nil, @druid, 'etdSubmitWF', 'registrar-approval', 'completed', version: 2, note: 'annotation', lane_id: 'lane1', current_status: 'queued')).to be_kind_of Dor::Workflow::Response::Update
|
185
|
-
end
|
186
|
-
|
187
|
-
it 'should throw exception if invalid status provided' do
|
188
|
-
expect { client.update_workflow_status(nil, @druid, 'accessionWF', 'publish', 'NOT_VALID_STATUS') }.to raise_error(ArgumentError)
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
describe '#update_workflow_error_status' do
|
193
|
-
let(:stubs) do
|
194
|
-
Faraday::Adapter::Test::Stubs.new do |stub|
|
195
|
-
stub.put("objects/#{@druid}/workflows/etdSubmitWF/reader-approval") do |env|
|
196
|
-
expect(env.body).to match(/status="error" errorMessage="Some exception" errorText="The optional stacktrace"/)
|
197
|
-
[201, {}, '{"next_steps":["submit-marc"]}']
|
198
|
-
end
|
199
|
-
|
200
|
-
stub.put("objects/#{@druid}/workflows/errorWF/reader-approval") do |_env|
|
201
|
-
[400, {}, '']
|
202
|
-
end
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
before do
|
207
|
-
allow(Deprecation).to receive(:warn)
|
208
|
-
end
|
209
|
-
|
210
|
-
it 'should update workflow status to error and return true if successful' do
|
211
|
-
client.update_workflow_error_status(nil, @druid, 'etdSubmitWF', 'reader-approval', 'Some exception', error_text: 'The optional stacktrace')
|
212
|
-
end
|
213
|
-
it 'should return false if the PUT to the DOR workflow service throws an exception' do
|
214
|
-
expect { client.update_workflow_error_status(nil, @druid, 'errorWF', 'reader-approval', 'completed') }.to raise_error(Dor::WorkflowException, /status 400/)
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
109
|
describe '#workflow_template' do
|
219
110
|
subject(:workflow_template) { client.workflow_template('etdSubmitWF') }
|
220
111
|
|
@@ -273,40 +164,6 @@ RSpec.describe Dor::Workflow::Client do
|
|
273
164
|
end
|
274
165
|
let(:xml) { '' }
|
275
166
|
|
276
|
-
context 'when repo is provided' do
|
277
|
-
before do
|
278
|
-
allow(Deprecation).to receive(:warn)
|
279
|
-
end
|
280
|
-
subject { client.workflow_status(repo: repo, druid: druid, workflow: workflow_name, process: step_name) }
|
281
|
-
|
282
|
-
context 'when a single result is returned' do
|
283
|
-
let(:xml) do
|
284
|
-
'<workflow><process name="registrar-approval" status="completed" /></workflow>'
|
285
|
-
end
|
286
|
-
|
287
|
-
it 'returns status as a string' do
|
288
|
-
expect(subject).to eq('completed')
|
289
|
-
end
|
290
|
-
end
|
291
|
-
end
|
292
|
-
|
293
|
-
context 'with positional arguments' do
|
294
|
-
before do
|
295
|
-
allow(Deprecation).to receive(:warn)
|
296
|
-
end
|
297
|
-
subject { client.workflow_status(repo, druid, workflow_name, step_name) }
|
298
|
-
|
299
|
-
context 'when a single result is returned' do
|
300
|
-
let(:xml) do
|
301
|
-
'<workflow><process name="registrar-approval" status="completed" /></workflow>'
|
302
|
-
end
|
303
|
-
|
304
|
-
it 'returns status as a string' do
|
305
|
-
expect(subject).to eq('completed')
|
306
|
-
end
|
307
|
-
end
|
308
|
-
end
|
309
|
-
|
310
167
|
context 'when a single result is returned' do
|
311
168
|
let(:xml) do
|
312
169
|
'<workflow><process name="registrar-approval" status="completed" /></workflow>'
|
@@ -366,85 +223,6 @@ RSpec.describe Dor::Workflow::Client do
|
|
366
223
|
end
|
367
224
|
end
|
368
225
|
|
369
|
-
describe '#workflow_xml' do
|
370
|
-
before do
|
371
|
-
allow(Deprecation).to receive(:warn)
|
372
|
-
end
|
373
|
-
context 'with positional args' do
|
374
|
-
subject(:workflow_xml) { client.workflow_xml('dor', 'druid:123', workflow) }
|
375
|
-
|
376
|
-
context 'when a workflow name is provided' do
|
377
|
-
let(:workflow) { 'etdSubmitWF' }
|
378
|
-
let(:xml) { '<workflow id="etdSubmitWF"><process name="registrar-approval" status="completed" /></workflow>' }
|
379
|
-
let(:stubs) do
|
380
|
-
Faraday::Adapter::Test::Stubs.new do |stub|
|
381
|
-
stub.get('dor/objects/druid:123/workflows/etdSubmitWF') do |_env|
|
382
|
-
[200, {}, xml]
|
383
|
-
end
|
384
|
-
end
|
385
|
-
end
|
386
|
-
|
387
|
-
it 'returns the xml for a given repository, druid, and workflow' do
|
388
|
-
expect(workflow_xml).to eq(xml)
|
389
|
-
end
|
390
|
-
end
|
391
|
-
|
392
|
-
context 'when no workflow name is provided' do
|
393
|
-
let(:workflow) { nil }
|
394
|
-
|
395
|
-
it 'raises an error' do
|
396
|
-
expect { workflow_xml }.to raise_error ArgumentError
|
397
|
-
end
|
398
|
-
end
|
399
|
-
end
|
400
|
-
context 'with keyword args' do
|
401
|
-
subject(:workflow_xml) { client.workflow_xml(druid: 'druid:123', workflow: workflow) }
|
402
|
-
|
403
|
-
# TODO: Remove this `context` block altogether when repos are wiped out for good
|
404
|
-
context 'when a repo is provided' do
|
405
|
-
subject(:workflow_xml) { client.workflow_xml(repo: 'dor', druid: 'druid:123', workflow: workflow) }
|
406
|
-
|
407
|
-
let(:workflow) { 'etdSubmitWF' }
|
408
|
-
let(:xml) { '<workflow id="etdSubmitWF"><process name="registrar-approval" status="completed" /></workflow>' }
|
409
|
-
let(:stubs) do
|
410
|
-
Faraday::Adapter::Test::Stubs.new do |stub|
|
411
|
-
stub.get('dor/objects/druid:123/workflows/etdSubmitWF') do |_env|
|
412
|
-
[200, {}, xml]
|
413
|
-
end
|
414
|
-
end
|
415
|
-
end
|
416
|
-
|
417
|
-
it 'returns the xml for a given repository, druid, and workflow' do
|
418
|
-
expect(workflow_xml).to eq(xml)
|
419
|
-
end
|
420
|
-
end
|
421
|
-
|
422
|
-
context 'when a workflow name is provided' do
|
423
|
-
let(:workflow) { 'etdSubmitWF' }
|
424
|
-
let(:xml) { '<workflow id="etdSubmitWF"><process name="registrar-approval" status="completed" /></workflow>' }
|
425
|
-
let(:stubs) do
|
426
|
-
Faraday::Adapter::Test::Stubs.new do |stub|
|
427
|
-
stub.get('/objects/druid:123/workflows/etdSubmitWF') do |_env|
|
428
|
-
[200, {}, xml]
|
429
|
-
end
|
430
|
-
end
|
431
|
-
end
|
432
|
-
|
433
|
-
it 'returns the xml for a given repository, druid, and workflow' do
|
434
|
-
expect(workflow_xml).to eq(xml)
|
435
|
-
end
|
436
|
-
end
|
437
|
-
|
438
|
-
context 'when no workflow name is provided' do
|
439
|
-
let(:workflow) { nil }
|
440
|
-
|
441
|
-
it 'raises an error' do
|
442
|
-
expect { workflow_xml }.to raise_error ArgumentError
|
443
|
-
end
|
444
|
-
end
|
445
|
-
end
|
446
|
-
end
|
447
|
-
|
448
226
|
describe '#all_workflows_xml' do
|
449
227
|
subject(:all_workflows_xml) { client.all_workflows_xml('druid:123') }
|
450
228
|
|
@@ -537,11 +315,11 @@ RSpec.describe Dor::Workflow::Client do
|
|
537
315
|
end
|
538
316
|
|
539
317
|
it 'parses out the active lifecycle' do
|
540
|
-
expect(client.active_lifecycle(druid: @druid, milestone_name: 'released').beginning_of_day).to eq(Time.parse('2010-06-15T16:08:58-0700').beginning_of_day)
|
318
|
+
expect(client.active_lifecycle(druid: @druid, milestone_name: 'released', version: '1').beginning_of_day).to eq(Time.parse('2010-06-15T16:08:58-0700').beginning_of_day)
|
541
319
|
end
|
542
320
|
|
543
321
|
it 'handles missing lifecycle' do
|
544
|
-
expect(client.active_lifecycle(druid: @druid, milestone_name: 'NOT_FOUND')).to be_nil
|
322
|
+
expect(client.active_lifecycle(druid: @druid, milestone_name: 'NOT_FOUND', version: '1')).to be_nil
|
545
323
|
end
|
546
324
|
end
|
547
325
|
|
@@ -729,31 +507,15 @@ RSpec.describe Dor::Workflow::Client do
|
|
729
507
|
end
|
730
508
|
end
|
731
509
|
|
732
|
-
|
733
|
-
let(:url) { "/objects/#{@druid}/workflows/accessionWF" }
|
510
|
+
let(:url) { "/objects/#{@druid}/workflows/accessionWF?version=5" }
|
734
511
|
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
client.delete_workflow(nil, @druid, 'accessionWF')
|
739
|
-
end
|
740
|
-
end
|
741
|
-
|
742
|
-
context 'with a version' do
|
743
|
-
let(:url) { "/objects/#{@druid}/workflows/accessionWF?version=5" }
|
744
|
-
|
745
|
-
it 'sends a delete request to the workflow service' do
|
746
|
-
expect(mock_http_connection).to receive(:delete).with(url).and_call_original
|
747
|
-
client.delete_workflow(nil, @druid, 'accessionWF', version: 5)
|
748
|
-
end
|
512
|
+
it 'sends a delete request to the workflow service' do
|
513
|
+
expect(mock_http_connection).to receive(:delete).with(url).and_call_original
|
514
|
+
client.delete_workflow(druid: @druid, workflow: 'accessionWF', version: 5)
|
749
515
|
end
|
750
516
|
end
|
751
517
|
|
752
518
|
describe '.stale_queued_workflows' do
|
753
|
-
before do
|
754
|
-
allow(Deprecation).to receive(:warn)
|
755
|
-
end
|
756
|
-
|
757
519
|
let(:stubs) do
|
758
520
|
Faraday::Adapter::Test::Stubs.new do |stub|
|
759
521
|
stub.get('workflow_queue/all_queued?hours-ago=24&limit=100') do |_env|
|
@@ -768,8 +530,7 @@ RSpec.describe Dor::Workflow::Client do
|
|
768
530
|
end
|
769
531
|
|
770
532
|
it 'returns an Array of Hashes containing each workflow step' do
|
771
|
-
ah = client.stale_queued_workflows
|
772
|
-
expect(Deprecation).to have_received(:warn).once
|
533
|
+
ah = client.stale_queued_workflows hours_ago: 24, limit: 100
|
773
534
|
expected = [
|
774
535
|
{ workflow: 'accessionWF', step: 'content-metadata', druid: 'dr:123', lane_id: 'lane1' },
|
775
536
|
{ workflow: 'assemblyWF', step: 'jp2-create', druid: 'dr:456', lane_id: 'lane2' }
|
@@ -779,10 +540,6 @@ RSpec.describe Dor::Workflow::Client do
|
|
779
540
|
end
|
780
541
|
|
781
542
|
describe '.count_stale_queued_workflows' do
|
782
|
-
before do
|
783
|
-
allow(Deprecation).to receive(:warn)
|
784
|
-
end
|
785
|
-
|
786
543
|
let(:stubs) do
|
787
544
|
Faraday::Adapter::Test::Stubs.new do |stub|
|
788
545
|
stub.get('workflow_queue/all_queued?hours-ago=48&count-only=true') do |_env|
|
@@ -792,16 +549,11 @@ RSpec.describe Dor::Workflow::Client do
|
|
792
549
|
end
|
793
550
|
|
794
551
|
it 'returns the number of queued workflow steps' do
|
795
|
-
expect(client.count_stale_queued_workflows(
|
796
|
-
expect(Deprecation).to have_received(:warn).once
|
552
|
+
expect(client.count_stale_queued_workflows(hours_ago: 48)).to eq(10)
|
797
553
|
end
|
798
554
|
end
|
799
555
|
|
800
556
|
describe '.lane_ids' do
|
801
|
-
before do
|
802
|
-
allow(Deprecation).to receive(:warn)
|
803
|
-
end
|
804
|
-
|
805
557
|
let(:stubs) do
|
806
558
|
Faraday::Adapter::Test::Stubs.new do |stub|
|
807
559
|
stub.get('workflow_queue/lane_ids?step=accessionWF:shelve') do |_env|
|
@@ -816,8 +568,7 @@ RSpec.describe Dor::Workflow::Client do
|
|
816
568
|
end
|
817
569
|
|
818
570
|
it 'returns the lane ids for a given workflow step' do
|
819
|
-
expect(client.lane_ids('
|
820
|
-
expect(Deprecation).to have_received(:warn).once
|
571
|
+
expect(client.lane_ids('accessionWF', 'shelve')).to eq(%w[lane1 lane2])
|
821
572
|
end
|
822
573
|
end
|
823
574
|
end
|