From 542ea037cca42a32eae4d95cb5fd8d6b64904617 Mon Sep 17 00:00:00 2001 From: Kirk Wang Date: Sat, 1 Oct 2022 08:14:52 -0700 Subject: [PATCH 1/2] make metadata not show in the manifest if nil --- .../v3/manifest_builder/record_property_builder.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/iiif_manifest/v3/manifest_builder/record_property_builder.rb b/lib/iiif_manifest/v3/manifest_builder/record_property_builder.rb index 13754b0..b4fea4d 100644 --- a/lib/iiif_manifest/v3/manifest_builder/record_property_builder.rb +++ b/lib/iiif_manifest/v3/manifest_builder/record_property_builder.rb @@ -44,7 +44,7 @@ def setup_manifest_from_record(manifest, record) manifest.label = ManifestBuilder.language_map(record.to_s) if record.to_s.present? manifest.summary = ManifestBuilder.language_map(record.description) if record.try(:description).present? manifest.behavior = viewing_hint if viewing_hint.present? - manifest.metadata = metadata_from_record(record) + manifest.metadata = metadata_from_record(record) if metadata_from_record(record).present? manifest.viewing_direction = viewing_direction if viewing_direction.present? manifest.service = services if search_service.present? manifest.rendering = populate_rendering if populate_rendering.present? From aeb86549dbf7640a8709581413d21458d9da48ab Mon Sep 17 00:00:00 2001 From: Kirk Wang Date: Mon, 3 Oct 2022 10:39:51 -0700 Subject: [PATCH 2/2] change the expectation from nil to not existing --- spec/lib/iiif_manifest/v3/manifest_factory_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/lib/iiif_manifest/v3/manifest_factory_spec.rb b/spec/lib/iiif_manifest/v3/manifest_factory_spec.rb index 6d3b335..9106a0b 100644 --- a/spec/lib/iiif_manifest/v3/manifest_factory_spec.rb +++ b/spec/lib/iiif_manifest/v3/manifest_factory_spec.rb @@ -259,7 +259,7 @@ def sequence_rendering it 'does not have a metadata element' do allow(book_presenter).to receive(:file_set_presenters).and_return([file_presenter]) - expect(result['metadata']).to eq nil + expect(result.key?('metadata')).to be false end end @@ -269,7 +269,7 @@ def sequence_rendering it 'has no metadata' do allow(book_presenter).to receive(:manifest_metadata).and_return(metadata) - expect(result['metadata']).to eq nil + expect(result.key?('metadata')).to be false end end @@ -400,7 +400,7 @@ def sequence_rendering expect(result['type']).to eq 'Manifest' end it "doesn't build manifests" do - expect(result['manifests']).to eq nil + expect(result.key?('metadata')).to be false end it 'builds items array from all the child file sets' do expect(result['items'].length).to eq 2 @@ -427,7 +427,7 @@ def sequence_rendering expect(result['type']).to eq 'Manifest' end it "doesn't build manifests" do - expect(result['manifests']).to eq nil + expect(result.key?('metadata')).to be false end it 'builds items array from all the child file sets' do expect(result['items'].length).to eq 1