Skip to content

Commit

Permalink
Merge pull request #6004 from avalonmediasystem/sup_file_rendering_link
Browse files Browse the repository at this point in the history
Generate correct rendering link in iiif manifest
  • Loading branch information
masaball authored Aug 26, 2024
2 parents 60f89bc + 15390b4 commit cf83eb0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/concerns/iiif_supplemental_file_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def supplemental_files_rendering(object)
end

def object_supplemental_file_url(object, supplemental_file)
if object.is_a? MasterFile
if object.is_a?(MasterFile) || object.is_a?(SpeedyAF::Proxy::MasterFile)
Rails.application.routes.url_helpers.master_file_supplemental_file_url(id: supplemental_file.id, master_file_id: object.id)
else
Rails.application.routes.url_helpers.media_object_supplemental_file_url(id: supplemental_file.id, media_object_id: object.id)
Expand Down
28 changes: 28 additions & 0 deletions spec/controllers/media_objects_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1853,6 +1853,34 @@
end

describe '#manifest' do
before do
login_as :administrator
end

context 'with supplemental files' do
let(:mf_supplemental_file) { FactoryBot.create(:supplemental_file) }
let(:mo_supplemental_file) { FactoryBot.create(:supplemental_file) }
let(:master_file) { FactoryBot.create(:master_file, media_object: media_object, supplemental_files: [mf_supplemental_file]) }
let(:media_object) { FactoryBot.create(:published_media_object, supplemental_files: [mo_supplemental_file]) }

before do
mf_supplemental_file.parent_id = master_file.id
mo_supplemental_file.parent_id = media_object.id
mf_supplemental_file.save
mo_supplemental_file.save
end

it 'should link to proper object route in rendering section' do
get 'manifest', params: { id: media_object.id, format: 'json' }
parsed_response = JSON.parse(response.body)
mo_rendering = parsed_response['rendering'].first
expect(mo_rendering['id']).to eq Rails.application.routes.url_helpers.media_object_supplemental_file_url(id: mo_supplemental_file.id, media_object_id: media_object.id)
item = parsed_response['items'].first
mf_rendering = item['rendering'].first
expect(mf_rendering['id']).to eq Rails.application.routes.url_helpers.master_file_supplemental_file_url(id: mf_supplemental_file.id, master_file_id: master_file.id)
end
end

context 'read from solr' do
let!(:master_file) { FactoryBot.create(:master_file, :with_derivative, media_object: media_object) }
let!(:media_object) { FactoryBot.create(:published_media_object, visibility: 'public') }
Expand Down

0 comments on commit cf83eb0

Please sign in to comment.