From a5e92a7b3228b358d684549eb03dd8b0aae520cf Mon Sep 17 00:00:00 2001 From: Justin Coyne Date: Fri, 23 Aug 2024 14:49:56 -0500 Subject: [PATCH] Don't try to deserialize XML as JSON --- app/models/public_json.rb | 2 ++ spec/factories/public_jsons.rb | 2 ++ 2 files changed, 4 insertions(+) diff --git a/app/models/public_json.rb b/app/models/public_json.rb index d1e339f7..d72c77bd 100644 --- a/app/models/public_json.rb +++ b/app/models/public_json.rb @@ -10,6 +10,8 @@ def data end def cocina_hash + return {} unless data_type == 'cocina' # Legacy metadata (xml), doesn't set this + JSON.parse(data) end end diff --git a/spec/factories/public_jsons.rb b/spec/factories/public_jsons.rb index 2c23e5ec..aebd4cc7 100644 --- a/spec/factories/public_jsons.rb +++ b/spec/factories/public_jsons.rb @@ -1,5 +1,7 @@ FactoryBot.define do factory :public_json do + data_type { 'cocina' } + data do Cocina::RSpec::Factories.build(:dro_with_metadata, id: purl.druid) .new(access: { view: 'world' },