Skip to content

Commit

Permalink
✅ add spec for default_collection_image in `ThumbnailPathServiceDec…
Browse files Browse the repository at this point in the history
…orator`

- 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.
  • Loading branch information
ShanaLMoore committed Nov 14, 2024
1 parent 7e77eb6 commit d0a437f
Showing 1 changed file with 22 additions and 0 deletions.
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

0 comments on commit d0a437f

Please sign in to comment.