From d0a437fae631e97869085a422749a9dacbf6b492 Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Thu, 14 Nov 2024 11:20:36 -0800 Subject: [PATCH] :white_check_mark: add spec for `default_collection_image` in `ThumbnailPathServiceDecorator` - Added a test for `default_collection_image` to verify it returns the site-specific default collection image when available. - Stubbed `Site.instance` to ensure the spec accurately tests behavior when a site default image is present or absent. --- .../hyrax/thumbnail_path_service_spec.rb | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/spec/services/hyrax/thumbnail_path_service_spec.rb b/spec/services/hyrax/thumbnail_path_service_spec.rb index 5aa1889ff..6a0ca2790 100644 --- a/spec/services/hyrax/thumbnail_path_service_spec.rb +++ b/spec/services/hyrax/thumbnail_path_service_spec.rb @@ -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