diff --git a/app/models/embed/purl/resource.rb b/app/models/embed/purl/resource.rb index b8909b2ac..393a6e57f 100644 --- a/app/models/embed/purl/resource.rb +++ b/app/models/embed/purl/resource.rb @@ -26,10 +26,6 @@ def description end end - def object_thumbnail? - @resource.attributes['thumb'].try(:value) == 'yes' || type == 'thumb' - end - def three_dimensional? @resource.attributes['type']&.value == '3d' end diff --git a/app/models/embed/purl/resource_file.rb b/app/models/embed/purl/resource_file.rb index 036844a0a..77126c326 100644 --- a/app/models/embed/purl/resource_file.rb +++ b/app/models/embed/purl/resource_file.rb @@ -47,15 +47,11 @@ def hierarchical_title end def primary? - primary_types = Settings.primary_mimetypes[resource.type] || [] - !thumbnail? && primary_types.include?(mimetype) + Array(Settings.primary_mimetypes[resource.type]).include?(mimetype) end def thumbnail? - return true if resource.object_thumbnail? - return false unless image? - - Settings.resource_types_that_contain_thumbnails.include?(resource.type) + image? && Settings.resource_types_that_contain_thumbnails.include?(resource.type) end def vtt diff --git a/spec/components/embed/media_tag_component_spec.rb b/spec/components/embed/media_tag_component_spec.rb index cb5ce2d96..e85915bbb 100644 --- a/spec/components/embed/media_tag_component_spec.rb +++ b/spec/components/embed/media_tag_component_spec.rb @@ -114,14 +114,9 @@ end context 'with file and object level thumbnails' do - let(:purl) { file_and_object_level_thumb_purl } + let(:purl) { file_thumb_purl } - it 'does not include object level thumbnails' do - expect(page).to have_css('[data-file-label="audio.mp3"]', visible: :all) - expect(page).not_to have_css('[data-file-label="thumb.jp2"]', visible: :all) - end - - it 'does not include file level thumbnails' do + it 'does not include thumbnails' do expect(page).not_to have_css('[data-file-label="audio_1.jp2"]', visible: :all) end @@ -170,7 +165,7 @@ describe 'with a poster' do context 'when a file level thumbnail is present' do - let(:purl) { file_and_object_level_thumb_purl } + let(:purl) { file_thumb_purl } let(:resource_iteration) { instance_double(ActionView::PartialIteration, index: 1) } let(:resource) { Embed::Purl.new(druid).contents.second } diff --git a/spec/fixtures/purl_fixtures.rb b/spec/fixtures/purl_fixtures.rb index 6fee1df20..b10300e3d 100644 --- a/spec/fixtures/purl_fixtures.rb +++ b/spec/fixtures/purl_fixtures.rb @@ -1129,7 +1129,7 @@ def audio_purl_multiple XML end - def file_and_object_level_thumb_purl + def file_thumb_purl <<-XML @@ -1148,9 +1148,6 @@ def file_and_object_level_thumb_purl - - - XML diff --git a/spec/models/embed/purl/resource_file_spec.rb b/spec/models/embed/purl/resource_file_spec.rb index 468d61ea7..eefd85f4f 100644 --- a/spec/models/embed/purl/resource_file_spec.rb +++ b/spec/models/embed/purl/resource_file_spec.rb @@ -96,25 +96,19 @@ let(:file) { double('File') } let(:resource_file) { described_class.new(resource, file, double('Rights')) } - it 'is true when the parent resource is an object level thumbnail' do - allow(resource).to receive(:object_thumbnail?).and_return(true) - expect(resource_file).to be_thumbnail - end - it 'is false when the file is not an image' do - allow(resource).to receive(:object_thumbnail?).and_return(false) allow(file).to receive(:attributes).and_return('mimetype' => double(value: 'not-an-image')) expect(resource_file).not_to be_thumbnail end - it 'is true when the parent resource type is whitelisted as having file-level thumbnail behaviors (and it is an image)' do - allow(resource).to receive_messages(object_thumbnail?: false, type: 'video') + it 'is true when the parent resource type is listed as having file-level thumbnail behaviors (and it is an image)' do + allow(resource).to receive_messages(type: 'video') allow(file).to receive(:attributes).and_return('mimetype' => double(value: 'image/jp2')) expect(resource_file).to be_thumbnail end - it 'is false when the parent resource type is not whitelisted as having file-level thumbnail behaviors (even if it is an image)' do - allow(resource).to receive_messages(object_thumbnail?: false, type: 'book') + it 'is false when the parent resource type is not listed as having file-level thumbnail behaviors (even if it is an image)' do + allow(resource).to receive_messages(type: 'book') allow(file).to receive(:attributes).and_return('mimetype' => double(value: 'image/jp2')) expect(resource_file).not_to be_thumbnail end diff --git a/spec/models/embed/purl/resource_spec.rb b/spec/models/embed/purl/resource_spec.rb index 4d0acf88c..ef6122d0a 100644 --- a/spec/models/embed/purl/resource_spec.rb +++ b/spec/models/embed/purl/resource_spec.rb @@ -57,30 +57,6 @@ end end - describe '#object_thumbnail?' do - subject { described_class.new('bc123df4567', node, instance_double(Dor::RightsAuth)) } - - let(:node) { instance_double(Nokogiri::XML::Node, attributes:) } - - context 'when type="thumb"' do - let(:attributes) { { 'type' => double(value: 'thumb') } } - - it { is_expected.to be_object_thumbnail } - end - - context 'when thumb="yes"' do - let(:attributes) { { 'thumb' => double(value: 'yes') } } - - it { is_expected.to be_object_thumbnail } - end - - context 'when any other value' do - let(:attributes) { { 'type' => double(value: 'image') } } - - it { is_expected.not_to be_object_thumbnail } - end - end - describe 'files' do it 'returns an array of Purl::Resource::ResourceFile objects' do stub_purl_xml_response_with_fixture(file_purl_xml)