mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-07 22:46:06 +00:00
Show SVG product images
This commit is contained in:
@@ -15,11 +15,15 @@ module Spree
|
||||
validate :no_attachment_errors
|
||||
|
||||
def variant(name)
|
||||
attachment.variant(SIZES[name])
|
||||
if attachment.variable?
|
||||
attachment.variant(SIZES[name])
|
||||
else
|
||||
attachment
|
||||
end
|
||||
end
|
||||
|
||||
def url(size)
|
||||
return unless attachment.variable?
|
||||
return unless attachment.attached?
|
||||
|
||||
Rails.application.routes.url_helpers.url_for(variant(size))
|
||||
end
|
||||
|
||||
@@ -240,5 +240,6 @@ module Openfoodnetwork
|
||||
Rails.autoloaders.main.ignore(Rails.root.join('app/webpacker'))
|
||||
|
||||
config.active_storage.service = ENV["S3_BUCKET"].present? ? :amazon : :local
|
||||
config.active_storage.content_types_to_serve_as_binary -= ["image/svg+xml"]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -21,11 +21,19 @@ module Spree
|
||||
)
|
||||
end
|
||||
|
||||
it "returns nil for unsupported formats" do
|
||||
it "returns download link for unsupported formats" do
|
||||
subject.attachment_blob.update_columns(
|
||||
content_type: "application/octet-stream"
|
||||
)
|
||||
|
||||
expect(subject.url(:small)).to match(
|
||||
%r|^http://test\.host/rails/active_storage/blobs/redirect/.+/logo-black\.png$|
|
||||
)
|
||||
end
|
||||
|
||||
it "returns nil when the attachment is missing" do
|
||||
subject.attachment = nil
|
||||
|
||||
expect(subject.url(:small)).to eq nil
|
||||
end
|
||||
end
|
||||
|
||||
@@ -51,7 +51,7 @@ describe "spree/orders/show.html.haml" do
|
||||
|
||||
render
|
||||
|
||||
expect(rendered).to have_no_css("img[src*='logo.png']")
|
||||
expect(rendered).to have_css("img[src*='logo.png']")
|
||||
expect(rendered).to have_content("R123456789")
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user