-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
16 changed files
with
166 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
module Robots | ||
module DorRepo | ||
module Accession | ||
# Publishing metadata and shelving files for object. | ||
class Publish < Robots::Robot | ||
def initialize | ||
super('accessionWF', 'publish') | ||
end | ||
|
||
def perform_work | ||
return LyberCore::ReturnState.new(status: :skipped, note: 'Admin policy objects are not published') if cocina_object.admin_policy? | ||
|
||
::Publish::MetadataTransferService.publish(druid:) | ||
EventFactory.create(druid:, event_type: 'publishing_complete', data: {}) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
module Robots | ||
# Base class for DSA robots. | ||
class Robot < LyberCore::Robot | ||
def cocina_object | ||
@cocina_object ||= CocinaObjectStore.find(druid) | ||
end | ||
|
||
def object_client | ||
raise 'Object Client should not be used from a DSA robot' | ||
end | ||
|
||
def workflow_service | ||
@workflow_service ||= ::WorkflowClientFactory.build | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe Robots::DorRepo::Accession::Publish, type: :robot do | ||
subject(:perform) { test_perform(robot, druid) } | ||
|
||
let(:druid) { 'druid:zz000zz0001' } | ||
let(:robot) { described_class.new } | ||
|
||
before do | ||
allow(CocinaObjectStore).to receive(:find).with(druid).and_return(object) | ||
allow(Publish::MetadataTransferService).to receive(:publish) | ||
allow(EventFactory).to receive(:create) | ||
end | ||
|
||
context 'when the object is an admin policy' do | ||
let(:object) { build(:admin_policy, id: druid) } | ||
|
||
it 'skips the object' do | ||
expect(perform.status).to eq 'skipped' | ||
expect(perform.note).to eq 'Admin policy objects are not published' | ||
expect(Publish::MetadataTransferService).not_to have_received(:publish) | ||
expect(EventFactory).not_to have_received(:create) | ||
end | ||
end | ||
|
||
context 'when the object is not an admin policy' do | ||
let(:object) { build(:dro, id: druid) } | ||
|
||
it 'publishes the object' do | ||
expect(perform).to be_nil # no return state defaults to completed. | ||
expect(Publish::MetadataTransferService).to have_received(:publish).with(druid: druid) | ||
expect(EventFactory).to have_received(:create).with(druid: druid, event_type: 'publishing_complete', data: {}) | ||
end | ||
end | ||
end |
Oops, something went wrong.