Skip to content

Commit

Permalink
unpin and update dor-services-client, update call
Browse files Browse the repository at this point in the history
  • Loading branch information
peetucket committed Apr 17, 2019
1 parent c515dac commit 31a4bb0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ gem 'assembly-utils'
gem 'dir_validator'
# gem 'dor-fetcher' # not supported anymore; only used by devel/get_dor_and_sdr_versions.rb script, which is not regularly used
gem 'dor-services', '< 6'
gem 'dor-services-client', '~> 0.6'
gem 'dor-services-client'
gem 'druid-tools'
gem 'harvestdor'
gem 'modsulator'
Expand Down
7 changes: 4 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,11 @@ GEM
stanford-mods-normalizer (~> 0.1)
systemu (~> 2.6)
uuidtools (~> 2.1.4)
dor-services-client (0.10.0)
dor-services-client (1.7.0)
activesupport (>= 4.2, < 6)
deprecation
faraday (~> 0.15)
moab-versioning (~> 4.0)
nokogiri (~> 1.8)
dor-workflow-service (2.12.0)
activesupport (>= 3.2.1, < 6)
Expand Down Expand Up @@ -378,7 +379,7 @@ DEPENDENCIES
dir_validator
dlss-capistrano (~> 3.1)
dor-services (< 6)
dor-services-client (~> 0.6)
dor-services-client
druid-tools
equivalent-xml
harvestdor
Expand All @@ -399,4 +400,4 @@ DEPENDENCIES
yard

BUNDLED WITH
1.16.6
1.17.2
4 changes: 2 additions & 2 deletions lib/pre_assembly/digital_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -498,9 +498,9 @@ def initialize_assembly_workflow

with_retries(max_tries: Dor::Config.dor.num_attempts, rescue: Exception, handler: PreAssembly.retry_handler('INITIALIZE_ASSEMBLY_WORKFLOW', method(:log))) do
begin
api_client.initialize_workflow(object: @druid.druid, wf_name: workflow_name)
api_client.object(@druid.druid).workflow.create(wf_name: workflow_name)
rescue StandardError => error
raise PreAssembly::UnknownError, "POST to assemblyWF endpoint at #{Dor::Config.dor_services_url} returned #{error}"
raise PreAssembly::UnknownError, "Call to #{Dor::Config.dor_services.url} returned #{error}"
end
end
end
Expand Down
24 changes: 6 additions & 18 deletions spec/digital_object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -800,13 +800,13 @@ def add_object_files(extension='tif')
describe '#initialize_assembly_workflow' do
before do
allow(@dobj).to receive(:api_client).and_return(client)
allow(Dor::Config).to receive(:dor_services_url).and_return(service_url)
allow(@dobj).to receive(:druid).and_return(@dru)
@dobj.init_assembly_wf = true
@dobj.druid = @druid
end

let(:client) { double }
let(:service_url) { 'http://example.edu/dor/services/endpoint' }
let(:service_url) { Dor::Config.dor_services.url }

context 'when @init_assembly_wf is false' do
before do
Expand All @@ -819,26 +819,14 @@ def add_object_files(extension='tif')
end
end

context 'when api client is successful' do
context 'when @init_assembly_wf is true' do
before do
allow(client).to receive(:initialize_workflow)
allow(client).to receive_message_chain(:object, :workflow, :create)
end

it 'starts the assembly workflow' do
expect { @dobj.initialize_assembly_workflow }.not_to raise_error
expect(client).to have_received(:initialize_workflow).once
end
end

context 'when the api client raises' do
before do
allow(client).to receive(:initialize_workflow).and_raise(Dor::Services::Client::UnexpectedResponse)
end

it 'raises an exception' do
expect { @dobj.initialize_assembly_workflow }.to raise_error(
/POST to assemblyWF endpoint at #{service_url} returned Dor::Services::Client::UnexpectedResponse/
)
expect(@dobj).to receive(:api_client)
@dobj.initialize_assembly_workflow
end
end
end
Expand Down

0 comments on commit 31a4bb0

Please sign in to comment.