dor-workflow-service 2.0.0 → 2.0.1

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
2
  SHA1:
3
- metadata.gz: 6cdb8d9e4d0b767532df5ea3f4c8e090b2120353
4
- data.tar.gz: 0bbd9f050f133cd1f2c924832bc4f2f390150398
3
+ metadata.gz: df4c4add80ccf7931772988c2d80b46aa0dc22f5
4
+ data.tar.gz: e21d8242604743d702940c4ef60cb815d8ac94ff
5
5
  SHA512:
6
- metadata.gz: 31e2c9ccbd940d6e1335797e68fb173a564fb70d8684b23135d58090552ba4a8f617da7e3492fdad44572022f7ac7a78b43ca73b01d80c036c8a3cd5e12ad291
7
- data.tar.gz: ce17ca0ce0d966e5076e19d3d92b6ca38d082c6d5891bf4b123e05e39a3bb1b8b2085617a30002b101465f1c180df8017c939f2b26a0b5c3f6682daafdb64259
6
+ metadata.gz: 3658909e6ed9419dae40f133332650b6a61f903768f95f033c3299f08ff17558434d2082912bdaca33a19ce737773f36849bc4c0d981be704a90c5712ad9073a
7
+ data.tar.gz: 86fef57843d7712d44bb848d13c74ec2b2359f44cfd328497d5aaf7db54996de70720a1f82e4e5c9b25cf1653c415e4ad2a7ba93b2baf4a2b3d7425ba2bfe307
@@ -18,7 +18,6 @@ module Dor
18
18
  # Create and update workflows
19
19
  class WorkflowService
20
20
  class << self
21
-
22
21
  @@handler = nil
23
22
  @@logger = nil
24
23
  @@resource = nil
@@ -486,6 +485,7 @@ module Dor
486
485
  faraday.response :logger if opts[:debug] # logs to STDOUT
487
486
  faraday.adapter :net_http_persistent # use Keep-Alive connections
488
487
  faraday.use Faraday::Response::RaiseError
488
+ faraday.options.params_encoder = Faraday::FlatParamsEncoder
489
489
  if opts.key? :timeout
490
490
  faraday.options.timeout = opts[:timeout]
491
491
  faraday.options.open_timeout = opts[:timeout]
@@ -551,13 +551,7 @@ module Dor
551
551
  with_retries(:max_tries => 2, :handler => @@handler, :rescue => workflow_service_exceptions_to_catch) do |attempt|
552
552
  @@logger.info "[Attempt #{attempt}] #{meth} #{base_url}/#{uri_string}"
553
553
 
554
- response = workflow_resource.send(meth, uri_string) do |req|
555
- req.body = payload unless meth == 'delete'
556
-
557
- req.params.update opts[:params] if opts[:params]
558
-
559
- req.headers.update opts.except(:params)
560
- end
554
+ response = send_workflow_resource_request(uri_string, meth, payload, opts)
561
555
 
562
556
  response.body
563
557
  end
@@ -566,6 +560,14 @@ module Dor
566
560
  msg += " (HTTP status #{e.response[:status]})" if e.respond_to?(:response) && e.response
567
561
  raise Dor::WorkflowException, msg
568
562
  end
563
+
564
+ def send_workflow_resource_request(uri_string, meth = 'get', payload = '', opts = {})
565
+ workflow_resource.send(meth, uri_string) do |req|
566
+ req.body = payload unless meth == 'delete'
567
+ req.params.update opts[:params] if opts[:params]
568
+ req.headers.update opts.except(:params)
569
+ end
570
+ end
569
571
  end
570
572
  end
571
573
  end
@@ -1,7 +1,7 @@
1
1
  module Dor
2
2
  module Workflow
3
3
  module Service
4
- VERSION = '2.0.0'
4
+ VERSION = '2.0.1'
5
5
  end
6
6
  end
7
7
  end
@@ -31,6 +31,7 @@ describe Dor::WorkflowService do
31
31
  let(:mock_http_connection) do
32
32
  Faraday.new(url: 'http://example.com/') do |builder|
33
33
  builder.use Faraday::Response::RaiseError
34
+ builder.options.params_encoder = Faraday::FlatParamsEncoder
34
35
 
35
36
  builder.adapter :test, stubs
36
37
  end
@@ -586,4 +587,31 @@ describe Dor::WorkflowService do
586
587
  expect(Dor::WorkflowService.get_lane_ids('dor', 'accessionWF', 'shelve')).to eq(%w(lane1 lane2))
587
588
  end
588
589
  end
590
+
591
+ describe '.workflow_resource_method' do
592
+ let(:stubs) do
593
+ Faraday::Adapter::Test::Stubs.new do |stub|
594
+ stub.get('x?complete=a&complete=b') do |env|
595
+ [200, {}, 'ab']
596
+ end
597
+ end
598
+ end
599
+
600
+ it 'uses the flat params encoder' do
601
+ response = Dor::WorkflowService.send(:send_workflow_resource_request, 'x?complete=a&complete=b')
602
+
603
+ expect(response.body).to eq 'ab'
604
+ expect(response.env.url.query).to eq 'complete=a&complete=b'
605
+ end
606
+ end
607
+
608
+ describe '.workflow_resource' do
609
+ before do
610
+ Dor::WorkflowService.configure 'http://example.com'
611
+ end
612
+
613
+ it 'defaults to using the flat params encoder' do
614
+ expect(Dor::WorkflowService.workflow_resource.options.params_encoder).to eq Faraday::FlatParamsEncoder
615
+ end
616
+ end
589
617
  end
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.0.0
4
+ version: 2.0.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: 2016-02-22 00:00:00.000000000 Z
12
+ date: 2016-03-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -239,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
239
239
  version: '0'
240
240
  requirements: []
241
241
  rubyforge_project:
242
- rubygems_version: 2.4.5.1
242
+ rubygems_version: 2.4.8
243
243
  signing_key:
244
244
  specification_version: 4
245
245
  summary: Provides convenience methods to work with the DOR Workflow Service