Skip to content

Commit

Permalink
Optional path argument and corresponding test
Browse files Browse the repository at this point in the history
  • Loading branch information
jermnelson committed Dec 16, 2019
1 parent d87a8ac commit 1d00915
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/jobs/moab_to_catalog_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ class MoabToCatalogJob < ApplicationJob

# @param [MoabStorageRoot] root mount containing the Moab
# @param [String] druid
# @param [String] path
def perform(root, druid, path)
# @param [String] optional path
def perform(root, druid, path=nil)
path = "#{root.storage_location}/#{DruidTools::Druid.new(druid).tree.join('/')}" if path? nil
moab = Moab::StorageObject.new(druid, path)
PreservedObjectHandler.new(druid, moab.current_version_id, moab.size, root).check_existence
end
Expand Down
14 changes: 14 additions & 0 deletions spec/jobs/moab_to_catalog_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,18 @@
job.perform(msr, druid, path)
end
end

describe '#perform without path' do
let(:msr) { create :moab_storage_root }
let(:path) { 'spec/fixtures/moab_storage_root01/sdr2objects/bj/102/hs/9687/bj102hs9687' }
let(:handler) { instance_double(PreservedObjectHandler) }

it 'builds a PreservedObjectHandler from MoabStorageRoot and druid if path is missing' do
expect(Moab::StorageObject).to receive(:new).with(druid, path).and_return(moab)
expect(PreservedObjectHandler).to receive(:new)
.with(druid, moab.current_version_id, moab.size, msr).and_return(handler)
expect(handler).to receive(:check_existence)
job.perform(msr, druid)
end
end
end

0 comments on commit 1d00915

Please sign in to comment.