refactor(gallery): extract representation_url_for method

This commit is contained in:
Eric Leroy-Terquem 2024-09-09 09:46:59 +02:00
parent bae752f1aa
commit 2882af43aa
No known key found for this signature in database
GPG key ID: 53D8FAECEF207605
3 changed files with 24 additions and 3 deletions

View file

@ -74,4 +74,20 @@ RSpec.describe GalleryHelper, type: :helper do
it { is_expected.to eq("pdf-placeholder.png") }
end
end
describe ".representation_url_for" do
subject { representation_url_for(attachment) }
context "when attachment is an image with no variant" do
let(:file) { fixture_file_upload('spec/fixtures/files/logo_test_procedure.png', 'image/png') }
it { is_expected.to eq("apercu-indisponible.png") }
end
context "when attachment is a pdf with no preview" do
let(:file) { fixture_file_upload('spec/fixtures/files/RIB.pdf', 'application/pdf') }
it { is_expected.to eq("pdf-placeholder.png") }
end
end
end