Skip to content

Commit

Permalink
☑️ Add test to clarify expected configuration
Browse files Browse the repository at this point in the history
With Knapsack, we're noticing that load path issues can be a subtle
problem.

With this commit, I'm testing the configuration to ensure that we have
the expected and correct lamba for generating IIIF Page's file titles.

Related to:

- https://github.com/scientist-softserv/adventist-dl/issues/628
  • Loading branch information
jeremyf committed Oct 13, 2023
1 parent 4fff283 commit eb7e6fa
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
# frozen_string_literal: true

# OVERRIDE IiifPrint v1.0.0 to not render thumbnail files in the UV
IiifPrint::ManifestBuilderServiceBehavior.module_eval do
module HykuKnapsack::ManifestBuilderServiceDecorator
def build_manifest(presenter:)
manifest = manifest_factory.new(presenter).to_h
hash = JSON.parse(manifest.to_json)
parent_and_child_solr_hits = parent_and_child_solr_hits(presenter) if @child_works.present?
hash = send("sanitize_v#{@version}", hash: hash, presenter: presenter, solr_doc_hits: parent_and_child_solr_hits)
if @child_works.present? && IiifPrint.config.sort_iiif_manifest_canvases_by
send("sort_canvases_v#{@version}",
hash: hash,
sort_field: IiifPrint.config.sort_iiif_manifest_canvases_by)
end
hash['rendering'] = rendering(presenter: presenter)
hash
returning_hash = super
returning_hash['rendering'] = rendering(presenter: presenter)
returning_hash
end

def rendering(presenter:)
Expand Down Expand Up @@ -51,3 +42,5 @@ def sanitize_label(label)
end
end
# rubocop:enable Metrics/BlockLength

Hyrax::ManifestBuilderService.prepend(HykuKnapsack::ManifestBuilderServiceDecorator)
2 changes: 1 addition & 1 deletion hyrax-webapp
Submodule hyrax-webapp updated 1 files
+2 −3 Dockerfile
44 changes: 44 additions & 0 deletions spec/config/initializers/iiif_print_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe IiifPrint do
describe '.config' do
describe '.unique_child_title_generator_function' do
subject { described_class.config.unique_child_title_generator_function }

it 'is defined in HykuKnapsack::Engine' do
# Verifying that we're using the configured title generator for PDFs.
# Triage for: https://github.com/scientist-softserv/adventist-dl/issues/628
expect(subject.source_location[0]).to(
eq(HykuKnapsack::Engine.root.join('config', 'initializers', 'iiif_print.rb').to_s)
)
end
end
describe '.sort_iiif_manifest_canvases_by' do
it do
# require 'byebug'; byebug
end
end
end

describe 'decoration of Hyrax::ManifestBuilderService' do
describe '#manifest_for method' do
subject { Hyrax::ManifestBuilderService.instance_method(:manifest_for).source_location[0] }

# Verifying that we're using the IIIF Print provided source_location; in particular we're not
# using the undecorated Hyrax version.
it { is_expected.to start_with(IiifPrint::Engine.root.to_s) }
end

describe '#build_manifest' do
subject { Hyrax::ManifestBuilderService.instance_method(:build_manifest).source_location[0] }

it do
is_expected.to(
eq(HykuKnapsack::Engine.root.join('app', 'services', 'iiif_print', 'manifest_builder_service_behavior_decorator.rb').to_s)
)
end
end
end
end

0 comments on commit eb7e6fa

Please sign in to comment.