Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions app/presenters/hyrax/iiif_manifest_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def file_set?
##
# @return [Array<DisplayImagePresenter>]
def file_set_presenters
member_presenters.select(&:file_set?)
member_presenters.select { |p| p.file_set? && (p.display_image || p.display_content) }
end

##
Expand Down Expand Up @@ -119,14 +119,14 @@ def member_presenters
##
# @return [Array<Hash{String => String}>]
def sequence_rendering
Array(try(:rendering_ids)).map do |file_set_id|
rendering = file_set_presenters.find { |p| p.id == file_set_id }
Array(try(:rendering_ids)).filter_map do |file_set_id|
rendering = member_presenters.find { |p| p.file_set? && p.id == file_set_id }
next unless rendering

{ '@id' => Hyrax::Engine.routes.url_helpers.download_url(rendering.id, host: hostname),
'format' => rendering.mime_type.presence || I18n.t("hyrax.manifest.unknown_mime_text"),
'label' => I18n.t("hyrax.manifest.download_text") + (rendering.label || '') }
end.flatten
end
end

##
Expand Down
28 changes: 28 additions & 0 deletions spec/presenters/hyrax/iiif_manifest_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -344,12 +344,40 @@
it 'has file sets the user can read' do
readable = valkyrie_create(:hyrax_file_set, :with_files, :in_work, work: work, read_users: [user])

allow_any_instance_of(Hyrax::IiifManifestPresenter::DisplayImagePresenter)
.to receive(:display_image).and_return(double('DisplayImage'))

expect(presenter.file_set_presenters)
.to contain_exactly(have_attributes(id: readable.id))
end
end
end
end

context 'when the work has both displayable and non-displayable file sets' do
let(:text_file_metadata) do
valkyrie_create(:hyrax_file_metadata, :original_file, :with_file,
file_set: text_file_set,
mime_type: 'text/plain')
end

let(:text_file_set) { FactoryBot.valkyrie_create(:hyrax_file_set) }
let(:work) { valkyrie_create(:monograph, members: [file_set, text_file_set, second_file_set]) }

before do
original_file_metadata
second_file_metadata
text_file_metadata
end

it 'only includes file sets with displayable content' do
expect(presenter.file_set_presenters.count).to eq 2
expect(presenter.file_set_presenters.map(&:id))
.to contain_exactly(file_set.id, second_file_set.id)
expect(presenter.file_set_presenters.map(&:id))
.not_to include(text_file_set.id)
end
end
end

describe '#manifest_metadata' do
Expand Down
Loading