From 82c3a01737e54bf1215af2ee96e35b77ab0d53e3 Mon Sep 17 00:00:00 2001 From: Justin Littman Date: Tue, 21 May 2019 14:35:16 -0400 Subject: [PATCH] Switched to passing version when creating workflows. --- Gemfile | 2 +- Gemfile.lock | 6 ++---- app/models/hydrus/admin_policy_object.rb | 2 +- app/models/hydrus/collection.rb | 4 +++- app/models/hydrus/processable.rb | 4 ++-- app/services/item_service.rb | 2 +- docker-compose.yml | 4 ++-- spec/features/models/item_spec.rb | 2 +- spec/models/hydrus/processable_spec.rb | 2 +- spec/services/item_service_spec.rb | 3 ++- 10 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Gemfile b/Gemfile index f90121b45..ea1e10df0 100644 --- a/Gemfile +++ b/Gemfile @@ -19,7 +19,7 @@ gem 'dor-services', '~> 6.1', require: false gem 'dor-services-client', '~> 1.1' gem 'rubydora', '~> 2.1' gem 'bagit', '~> 0.4' -gem 'dor-workflow-client', '~> 3.1' +gem 'dor-workflow-client', '~> 3.2' gem 'net-http-persistent', '~> 2.9' # https://github.com/sul-dlss/dor-workflow-service/issues/44 gem 'blacklight', '~> 6.19' gem 'cancancan', '~> 1.17' diff --git a/Gemfile.lock b/Gemfile.lock index 3cd961f5e..05a069f13 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -204,13 +204,11 @@ GEM faraday (~> 0.15) moab-versioning (~> 4.0) nokogiri (~> 1.8) - dor-workflow-client (3.1.0) + dor-workflow-client (3.2.0) activesupport (>= 3.2.1, < 6) - confstruct (>= 0.2.7, < 2) deprecation (~> 0) faraday (~> 0.9, >= 0.9.2) faraday_middleware - net-http-persistent (>= 2.9.4, < 4.a) nokogiri (~> 1.6) dor-workflow-service (2.12.0) activesupport (>= 3.2.1, < 6) @@ -581,7 +579,7 @@ DEPENDENCIES dlss-capistrano dor-services (~> 6.1) dor-services-client (~> 1.1) - dor-workflow-client (~> 3.1) + dor-workflow-client (~> 3.2) dynamic_form equivalent-xml factory_bot_rails diff --git a/app/models/hydrus/admin_policy_object.rb b/app/models/hydrus/admin_policy_object.rb index a87befc1d..0fb206e65 100644 --- a/app/models/hydrus/admin_policy_object.rb +++ b/app/models/hydrus/admin_policy_object.rb @@ -88,7 +88,7 @@ def self.create(user) args = [user, 'adminPolicy', dconf.ur_apo_druid] response = Hydrus::GenericObject.register_dor_object(*args) apo = Hydrus::AdminPolicyObject.find(response[:pid]) - workflow_client.create_workflow_by_name(response[:pid], Dor::Config.hydrus.app_workflow) + workflow_client.create_workflow_by_name(response[:pid], Dor::Config.hydrus.app_workflow, version: apo.current_version) apo.remove_relationship :has_model, 'info:fedora/afmodel:Dor_AdminPolicyObject' apo.assert_content_model diff --git a/app/models/hydrus/collection.rb b/app/models/hydrus/collection.rb index dd2d4957e..d7a68b1cb 100644 --- a/app/models/hydrus/collection.rb +++ b/app/models/hydrus/collection.rb @@ -94,9 +94,11 @@ def self.create(user) # Create the object, with the correct model. apo = Hydrus::AdminPolicyObject.create(user) response = Hydrus::GenericObject.register_dor_object(user, 'collection', apo.pid) - workflow_client.create_workflow_by_name(response[:pid], Dor::Config.hydrus.app_workflow) coll = Hydrus::Collection.find(response[:pid]) + # Create workflow + workflow_client.create_workflow_by_name(coll.pid, Dor::Config.hydrus.app_workflow, version: coll.current_version) + coll.remove_relationship :has_model, 'info:fedora/afmodel:Dor_Collection' coll.assert_content_model # Set the item_type, and add some Hydrus-specific info to identityMetadata. diff --git a/app/models/hydrus/processable.rb b/app/models/hydrus/processable.rb index 79ad85fa1..40a45e09e 100644 --- a/app/models/hydrus/processable.rb +++ b/app/models/hydrus/processable.rb @@ -56,12 +56,12 @@ def start_common_assembly # automated tests. def start_assembly_wf return unless should_start_assembly_wf - workflow_client.create_workflow_by_name(pid, 'assemblyWF') + workflow_client.create_workflow_by_name(pid, 'assemblyWF', version: current_version) end # Kicks off hydrusAssemblyWF def start_hydrus_wf - workflow_client.create_workflow_by_name(pid, Dor::Config.hydrus.app_workflow) + workflow_client.create_workflow_by_name(pid, Dor::Config.hydrus.app_workflow, version: current_version) end # Returns value of Dor::Config.hydrus.start_assembly_wf. diff --git a/app/services/item_service.rb b/app/services/item_service.rb index 658c8436f..3700d77ab 100644 --- a/app/services/item_service.rb +++ b/app/services/item_service.rb @@ -40,9 +40,9 @@ def validate! # @return [Hydrus::Item] def build_item(item_type) registration_response = Hydrus::GenericObject.register_dor_object(user, 'item', collection.apo_pid) - workflow_client.create_workflow_by_name(registration_response[:pid], Dor::Config.hydrus.app_workflow) Hydrus::Item.find(registration_response[:pid]).tap do |item| + workflow_client.create_workflow_by_name(item.pid, Dor::Config.hydrus.app_workflow, version: item.current_version) item.remove_relationship :has_model, 'info:fedora/afmodel:Dor_Item' item.assert_content_model # Set the item_type, and add some Hydrus-specific info to identityMetadata. diff --git a/docker-compose.yml b/docker-compose.yml index 7c5ffbeed..9e87708de 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -62,8 +62,8 @@ services: ports: - 3003:3000 environment: - SOLR_URL: http://solr:8983/solr/hydrus-test - SETTINGS__SOLRIZER_URL: http://solr:8983/solr/hydrus-test +# SOLR_URL: http://solr:8983/solr/hydrus-test + SETTINGS__solr__url: http://solr:8983/solr/hydrus-test SETTINGS__FEDORA_URL: http://fedoraAdmin:fedoraAdmin@fcrepo:8080/fedora SETTINGS__SURI__URL: http://suri:3000 SETTINGS__WORKFLOW_URL: http://workflow:3000 diff --git a/spec/features/models/item_spec.rb b/spec/features/models/item_spec.rb index a63f32338..7687ce4fa 100644 --- a/spec/features/models/item_spec.rb +++ b/spec/features/models/item_spec.rb @@ -94,7 +94,7 @@ 'hydrusAssemblyWF', 'approve', 'completed') expect(mock_wf_client).to have_received(:update_workflow_status).with('dor', hi.pid, 'hydrusAssemblyWF', 'start-assembly', 'completed') - expect(mock_wf_client).to have_received(:create_workflow_by_name).with(hi.pid, 'assemblyWF') + expect(mock_wf_client).to have_received(:create_workflow_by_name).with(hi.pid, 'assemblyWF', version: '1') end end diff --git a/spec/models/hydrus/processable_spec.rb b/spec/models/hydrus/processable_spec.rb index fe31a3b69..895ba8848 100644 --- a/spec/models/hydrus/processable_spec.rb +++ b/spec/models/hydrus/processable_spec.rb @@ -22,7 +22,7 @@ end it 'can exercise start_hydrus_wf() stubbed' do - expect(mock_wf_client).to receive(:create_workflow_by_name).with(@go.pid, 'hydrusAssemblyWF') + expect(mock_wf_client).to receive(:create_workflow_by_name).with(@go.pid, 'hydrusAssemblyWF', version: '1') @go.start_hydrus_wf() end diff --git a/spec/services/item_service_spec.rb b/spec/services/item_service_spec.rb index 131ff8f7f..fce4c5582 100644 --- a/spec/services/item_service_spec.rb +++ b/spec/services/item_service_spec.rb @@ -27,7 +27,8 @@ expect(item.requires_terms_acceptance(user, collection)).to eq(true) expect(item.accepted_terms_of_deposit).to eq('false') expect(item.terms_of_deposit_accepted?).to eq(false) - expect(workflow_client).to have_received(:create_workflow_by_name).with(String, 'hydrusAssemblyWF') + expect(workflow_client).to have_received(:create_workflow_by_name).with(String, 'hydrusAssemblyWF', + version: '1') end end