Skip to content

Commit

Permalink
Merge 9f0e85f into eafbfdd
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Nov 21, 2019
2 parents eafbfdd + 9f0e85f commit 9455f52
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ end
# general Ruby/Rails gems
gem 'aws-sdk-s3', '~> 1.17'
gem 'config' # Settings to manage configs on different instances
gem 'dor-workflow-client', '~> 3.3' # audit errors are reported to the workflow service
gem 'dor-workflow-client', '~> 3.8' # audit errors are reported to the workflow service
gem 'honeybadger' # for error reporting / tracking / notifications
gem 'jbuilder', '~> 2.5' # Build JSON APIs with ease.
gem 'okcomputer' # ReST endpoint with upness status
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ DEPENDENCIES
config
coveralls
dlss-capistrano
dor-workflow-client (~> 3.3)
dor-workflow-client (~> 3.8)
druid-tools
factory_bot_rails (~> 4.0)
hirb
Expand Down
11 changes: 8 additions & 3 deletions app/services/workflow_reporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

# send errors to preservationAuditWF workflow for an object via ReST calls.
class WorkflowReporter
DOR = 'dor'
PRESERVATIONAUDITWF = 'preservationAuditWF'
NO_WORKFLOW_HOOKUP = 'no workflow hookup - assume you are in test or dev environment'
COMPLETED = 'completed'
Expand All @@ -11,15 +10,21 @@ class WorkflowReporter
# see issue sul-dlss/dor-workflow-service#50 for more context
def self.report_error(druid, process_name, error_message)
if Settings.workflow_services_url.present?
workflow_client.update_workflow_error_status(DOR, "druid:#{druid}", PRESERVATIONAUDITWF, process_name, error_message)
workflow_client.update_error_status(druid: "druid:#{druid}",
workflow: PRESERVATIONAUDITWF,
process: process_name,
error_msg: error_message)
else
Rails.logger.warn(NO_WORKFLOW_HOOKUP)
end
end

def self.report_completed(druid, process_name)
if Settings.workflow_services_url.present?
workflow_client.update_workflow_status(DOR, "druid:#{druid}", PRESERVATIONAUDITWF, process_name, COMPLETED)
workflow_client.update_status(druid: "druid:#{druid}",
workflow: PRESERVATIONAUDITWF,
process: process_name,
status: COMPLETED)
else
Rails.logger.warn(NO_WORKFLOW_HOOKUP)
end
Expand Down
16 changes: 12 additions & 4 deletions spec/services/workflow_reporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
allow(Dor::Workflow::Client).to receive(:new).and_return(stub_client)
end

let(:stub_client) { instance_double(Dor::Workflow::Client, update_workflow_error_status: true) }
let(:stub_client) { instance_double(Dor::Workflow::Client, update_error_status: true) }

let(:process_name) { 'moab-valid' }

Expand All @@ -19,7 +19,11 @@
# because we always get true the from the dor-workflow-service gem
# see issue sul-dlss/dor-workflow-client#50 for more context
expect(described_class.report_error(druid, process_name, result)).to be true
expect(stub_client).to have_received(:update_workflow_error_status).with('dor', "druid:#{druid}", 'preservationAuditWF', process_name, result)
expect(stub_client).to have_received(:update_error_status)
.with(druid: "druid:#{druid}",
workflow: 'preservationAuditWF',
process: process_name,
error_msg: result)
end
end

Expand All @@ -28,12 +32,16 @@
allow(Dor::Workflow::Client).to receive(:new).and_return(stub_client)
end

let(:stub_client) { instance_double(Dor::Workflow::Client, update_workflow_status: true) }
let(:stub_client) { instance_double(Dor::Workflow::Client, update_status: true) }
let(:process_name) { 'preservation-audit' }

it 'returns true' do
expect(described_class.report_completed(druid, process_name)).to be true
expect(stub_client).to have_received(:update_workflow_status).with('dor', "druid:#{druid}", 'preservationAuditWF', process_name, 'completed')
expect(stub_client).to have_received(:update_status)
.with(druid: "druid:#{druid}",
workflow: 'preservationAuditWF',
process: process_name,
status: 'completed')
end
end
end

0 comments on commit 9455f52

Please sign in to comment.