From 3c3f512c43ad249980c5417ca884655620e00986 Mon Sep 17 00:00:00 2001 From: Mason Ballengee Date: Tue, 31 Oct 2023 09:49:16 -0400 Subject: [PATCH] Fix manifest generation for playlist item with deleted source --- Gemfile.lock | 2 +- app/models/iiif_playlist_canvas_presenter.rb | 2 ++ spec/controllers/playlists_controller_spec.rb | 12 ++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 158a5dce97..e31a5b2fb7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -67,7 +67,7 @@ GIT GIT remote: https://github.com/samvera-labs/iiif_manifest.git - revision: c8ca0c6e54517446419c20221260eaf3dcf46d4e + revision: c7467b4ae32934f161bd2cabdd741ec9293cefe6 branch: main specs: iiif_manifest (1.3.1) diff --git a/app/models/iiif_playlist_canvas_presenter.rb b/app/models/iiif_playlist_canvas_presenter.rb index 41f9b424aa..1aee9ef4ba 100644 --- a/app/models/iiif_playlist_canvas_presenter.rb +++ b/app/models/iiif_playlist_canvas_presenter.rb @@ -40,6 +40,7 @@ def master_file end def part_of + return if master_file.nil? [{ "@id" => Rails.application.routes.url_helpers.manifest_media_object_url(master_file.media_object_id).to_s, "type" => "manifest" @@ -47,6 +48,7 @@ def part_of end def item_metadata + return if master_file.nil? [ metadata_field('Title', master_file.media_object.title), metadata_field('Date', master_file.media_object.date_issued), diff --git a/spec/controllers/playlists_controller_spec.rb b/spec/controllers/playlists_controller_spec.rb index a1864d3d72..bc7527eb44 100644 --- a/spec/controllers/playlists_controller_spec.rb +++ b/spec/controllers/playlists_controller_spec.rb @@ -618,5 +618,17 @@ expect(parsed_response['items'][1]['items'][0].keys).to_not include 'items' end end + + context "playlist item with deleted source" do + before do + master_file.delete + end + + it "returns a blank canvas" do + get :manifest, format: 'json', params: { id: playlist.id }, session: valid_session + parsed_response = JSON.parse(response.body) + expect(parsed_response['items'][0]['items'][0].keys).to_not include 'items' + end + end end end