Skip to content

Commit

Permalink
use MoabStorageService for controllers (#1237)
Browse files Browse the repository at this point in the history
use MoabStorageService for controllers
  • Loading branch information
mjgiarlo committed Nov 15, 2019
2 parents 65076ef + 67d9ac9 commit 4575a7f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
6 changes: 1 addition & 5 deletions app/controllers/objects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,9 @@ def csv_checksum_list
end

def checksum_for_object(druid)
content_group = retrieve_file_group(druid)
content_group = MoabStorageService.retrieve_content_file_group(druid)
content_group.path_hash.map do |file, signature|
{ filename: file, md5: signature.md5, sha1: signature.sha1, sha256: signature.sha256, filesize: signature.size }
end
end

def retrieve_file_group(druid)
Moab::StorageServices.retrieve_file_group('content', druid)
end
end
8 changes: 8 additions & 0 deletions app/services/moab_storage_service.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

# Responsibility: interactions with Moab storage to support read-only access for ReST API calls
class MoabStorageService
def self.retrieve_content_file_group(druid)
Moab::StorageServices.retrieve_file_group('content', druid)
end
end
15 changes: 15 additions & 0 deletions spec/services/moab_storage_service_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe MoabStorageService do
let(:druid) { 'jj925bx9565' }

describe '.retrieve_content_file_group' do
it 'calls Moab::StorageServices.retrieve_file_group for "content"' do
allow(Moab::StorageServices).to receive(:retrieve_file_group).with('content', druid)
described_class.retrieve_content_file_group(druid)
expect(Moab::StorageServices).to have_received(:retrieve_file_group).with('content', druid)
end
end
end

0 comments on commit 4575a7f

Please sign in to comment.