Skip to content
This repository has been archived by the owner on May 11, 2022. It is now read-only.

Commit

Permalink
Merge pull request #472 from sul-dlss/pass_object
Browse files Browse the repository at this point in the history
Pass an item to PublicDescMetadataService.new
  • Loading branch information
mjgiarlo committed Jan 9, 2019
2 parents c47d72e + 0a86cf7 commit d5990b1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dor-services.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Gem::Specification.new do |s|
s.add_dependency 'activesupport', '>= 4.2.10', '< 6.0.0'
s.add_dependency 'confstruct', '~> 0.2.7'
s.add_dependency 'deprecation', '~> 0'
s.add_dependency 'dor-services-client', '~> 0.4'
s.add_dependency 'dor-services-client', '~> 0.9'
s.add_dependency 'equivalent-xml', '~> 0.5', '>= 0.5.1' # 5.0 insufficient
s.add_dependency 'json', '>= 1.8.1'
s.add_dependency 'net-sftp', '~> 2.1'
Expand Down
2 changes: 1 addition & 1 deletion lib/dor/models/concerns/publishable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def publish_metadata

# Call dor services app to have it publish the metadata
def publish_metadata_remotely
Dor::Services::Client.publish(object: pid)
Dor::Services::Client.object(pid).publish
end
deprecation_deprecate publish_metadata_remotely: 'use Dor::Services::Client.publish instead'
end
Expand Down
2 changes: 1 addition & 1 deletion lib/dor/services/publish_metadata_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def transfer_metadata
transfer_to_document_store(item.datastreams[stream].content.to_s, stream) if item.datastreams[stream]
end
transfer_to_document_store(PublicXmlService.new(item).to_xml, 'public')
transfer_to_document_store(PublicDescMetadataService.new(self).to_xml, 'mods')
transfer_to_document_store(PublicDescMetadataService.new(item).to_xml, 'mods')
end

# Clear out the document cache for this item
Expand Down
4 changes: 3 additions & 1 deletion spec/models/concerns/publishable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,12 @@ class PublishableItem < ActiveFedora::Base
before do
Dor::Config.push! { |config| config.dor_services.url 'https://lyberservices-test.stanford.edu/dor' }
stub_request(:post, 'https://lyberservices-test.stanford.edu/dor/v1/objects/druid:ab123cd4567/publish')
allow(Deprecation).to receive(:warn)
end

it 'hits the correct url' do
expect(Deprecation).to receive(:warn)
expect(item.publish_metadata_remotely).to be true
expect(Deprecation).to have_received(:warn)
end
end
end
14 changes: 12 additions & 2 deletions spec/services/publish_metadata_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,14 @@ class PublishableItem < ActiveFedora::Base
</mods:mods>
EOXML
end
let(:md_service) { instance_double(Dor::PublicDescMetadataService, to_xml: mods, ng_xml: Nokogiri::XML(mods)) }
let(:dc_service) { instance_double(Dor::DublinCoreService, ng_xml: Nokogiri::XML('<oai_dc:dc></oai_dc:dc>')) }
let(:public_service) { instance_double(Dor::PublicXmlService, to_xml: '<publicObject></publicObject>') }

before do
allow_any_instance_of(Dor::PublicDescMetadataService).to receive(:to_xml).and_return(mods)
allow_any_instance_of(Dor::PublicDescMetadataService).to receive(:ng_xml).and_return(Nokogiri::XML(mods))
allow(Dor::DublinCoreService).to receive(:new).and_return(dc_service)
allow(Dor::PublicXmlService).to receive(:new).and_return(public_service)
allow(Dor::PublicDescMetadataService).to receive(:new).and_return(md_service)
end

context 'with an item' do
Expand All @@ -128,10 +133,15 @@ class PublishableItem < ActiveFedora::Base
expect_any_instance_of(Dor::PublishMetadataService).to receive(:transfer_to_document_store).with(/<mods:mods/, 'mods')
expect_any_instance_of(Dor::PublishMetadataService).to receive(:publish_notify_on_success).with(no_args)
end

it 'identityMetadta, contentMetadata, rightsMetadata, generated dublin core, and public xml' do
item.rightsMetadata.content = "<rightsMetadata><access type='discover'><machine><world/></machine></access></rightsMetadata>"
service.publish
expect(Dor::DublinCoreService).to have_received(:new).with(item)
expect(Dor::PublicXmlService).to have_received(:new).with(item)
expect(Dor::PublicDescMetadataService).to have_received(:new).with(item)
end

it 'even when rightsMetadata uses xml namespaces' do
item.rightsMetadata.content = %q(<rightsMetadata xmlns="http://hydra-collab.stanford.edu/schemas/rightsMetadata/v1">
<access type='discover'><machine><world/></machine></access></rightsMetadata>)
Expand Down

0 comments on commit d5990b1

Please sign in to comment.