diff --git a/Gemfile b/Gemfile index a30f476bb..56798fea3 100644 --- a/Gemfile +++ b/Gemfile @@ -38,7 +38,7 @@ gem 'rsolr', '~> 1.1.0' gem 'devise', '~> 3.0' gem 'devise-guests', '~> 0.3' gem 'iiif-presentation', github: 'iiif/osullivan', branch: 'development' -gem 'geo_concerns', '~> 0.3.2' +gem 'geo_concerns', '~> 0.3.3' # PDF generation gem 'prawn' diff --git a/Gemfile.lock b/Gemfile.lock index 505780161..858eae657 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -285,7 +285,7 @@ GEM ffi (1.9.14) font-awesome-rails (4.7.0.0) railties (>= 3.2, < 5.1) - geo_concerns (0.3.2) + geo_concerns (0.3.3) bunny curation_concerns (>= 1.6) geoblacklight_messaging @@ -750,7 +750,7 @@ DEPENDENCIES ezid-client factory_girl_rails fcrepo_wrapper (~> 0.6.0) - geo_concerns (~> 0.3.2) + geo_concerns (~> 0.3.3) hydra-derivatives (= 3.1.3) hydra-pcdm! hydra-role-management (~> 0.2.0) diff --git a/app/services/geo_concerns/discovery/document_builder/slug_builder.rb b/app/services/geo_concerns/discovery/document_builder/slug_builder.rb index fe162295a..64446b1de 100644 --- a/app/services/geo_concerns/discovery/document_builder/slug_builder.rb +++ b/app/services/geo_concerns/discovery/document_builder/slug_builder.rb @@ -9,16 +9,22 @@ def initialize(geo_concern) end def build(document) + document.provenance = provenance document.slug = slug end + # Overrides the geo_concerns provenance to match + # match existing geoblacklight metadata. + def provenance + Plum.config[:geoblacklight_provenance] + end + # Returns the document slug for use in discovery systems. # @return [String] document slug def slug identifier = geo_concern.identifier || geo_concern.id id = identifier.gsub(%r(ark:/\d{5}/), '') - return id unless geo_concern.provenance - "#{geo_concern.provenance.parameterize}-#{id}" + "#{provenance.parameterize}-#{id}" end end end diff --git a/config/config.yml b/config/config.yml index 45ad64232..af0f6aedc 100644 --- a/config/config.yml +++ b/config/config.yml @@ -38,6 +38,7 @@ defaults: &defaults server: 'amqp://localhost:5672' exchange: 'plum_events' geo_derivatives_path: <%= File.join(Rails.root, 'tmp', 'geo-derivatives') %> + geoblacklight_provenance: 'Princeton' development: <<: *defaults diff --git a/spec/services/geo_concerns/slug_builder_spec.rb b/spec/services/geo_concerns/slug_builder_spec.rb index bb0261104..55174a937 100644 --- a/spec/services/geo_concerns/slug_builder_spec.rb +++ b/spec/services/geo_concerns/slug_builder_spec.rb @@ -3,25 +3,19 @@ describe GeoConcerns::Discovery::DocumentBuilder::SlugBuilder do subject { described_class.new(geo_concern_presenter) } + let(:document) { instance_double('Document') } + let(:plum_config) { { geoblacklight_provenance: 'Princeton' } } let(:geo_concern_presenter) { GeoConcerns::VectorWorkShowPresenter.new(SolrDocument.new(geo_concern.to_solr), nil) } - let(:geo_concern) { FactoryGirl.build(:vector_work, attributes) } - let(:attributes) { { id: 'geo-work-1', - title: ['Geo Work'], - description: ['This is a Geo Work'], - creator: ['Yosiwo George'], - publisher: ['National Geographic'], - spatial: ['Micronesia'], - temporal: ['2011'], - subject: ['Human settlements'], - language: ['Esperanto'], - identifier: 'ark:/99999/fk4' - } - } + let(:geo_concern) { FactoryGirl.build(:vector_work, identifier: 'ark:/99999/fk4') } - describe 'vector work slug' do - it 'uses ark noid fowlling the provenance' do - document = instance_double('Document') - expect(document).to receive(:slug=).with('princeton-university-library-fk4') + before do + allow(Plum).to receive(:config).and_return(plum_config) + end + + describe 'vector work document' do + it 'creates a slug with an ark noid and uses a locally configured provenance' do + expect(document).to receive(:provenance=).with('Princeton') + expect(document).to receive(:slug=).with('princeton-fk4') subject.build(document) end end