Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[i886] - update logic to fix collection thumbnail bug #2381

Merged
merged 2 commits into from
Nov 14, 2024
Merged
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
6 changes: 5 additions & 1 deletion app/services/hyrax/thumbnail_path_service_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ def call(object)
collection_thumbnail = CollectionBrandingInfo.where(collection_id: object.id.to_s, role: "thumbnail").first
return collection_thumbnail.local_path.gsub(Hyrax.config.branding_path.to_s, '/branding') if collection_thumbnail

return default_image if object.try(:thumbnail_id).blank?
if object.try(:thumbnail_id).blank?
return default_collection_image if object.try(:collection?)
return default_image
end

thumb = fetch_thumbnail(object)
return default_collection_image unless thumb

return call(thumb) unless thumb.file_set?
if audio?(thumb)
audio_image
Expand Down
2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
config.force_ssl = true
config.ssl_options = {
redirect: {
exclude: -> request { request.path == '/healthz' }
exclude: ->(request) { request.path == '/healthz' }
laritakr marked this conversation as resolved.
Show resolved Hide resolved
}
}
# Use the lowest log level to ensure availability of diagnostic information
Expand Down
22 changes: 22 additions & 0 deletions spec/services/hyrax/thumbnail_path_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,26 @@
end
end
end

describe '.default_collection_image' do
context 'when the site has a default collection image' do
let(:collection_image) { '/assets/site_default_collection_image.png' }
let(:site_instance_double) { instance_double(Site, default_collection_image: double('DefaultCollectionImage', url: collection_image)) }

before do
# Stub Site.instance to return our site_instance_double with the expected url
allow(Site).to receive(:instance).and_return(site_instance_double)
end

it 'returns the default collection image from the site' do
expect(described_class.default_collection_image).to eq(collection_image)
end
end

context 'when the site does not have a default collection image' do
it 'returns the Hyrax default collection image' do
expect(described_class.default_collection_image).to eq(ActionController::Base.helpers.image_path('default.png'))
end
end
end
end
Loading