mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-15 23:57:48 +00:00
Merge pull request #12068 from mkllnk/dfc-enterprise-promo-image
Add promo image to DFC Enterprise API
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class EnterpriseBuilder < DfcBuilder
|
||||
def self.enterprise(enterprise)
|
||||
def self.enterprise(enterprise) # rubocop:disable Metrics/AbcSize
|
||||
# The ABC size of this method should shrink when our custom attributes are
|
||||
# in the DFC standard.
|
||||
|
||||
variants = enterprise.supplied_variants.to_a
|
||||
catalog_items = variants.map(&method(:catalog_item))
|
||||
supplied_products = catalog_items.map(&:product)
|
||||
@@ -27,6 +30,7 @@ class EnterpriseBuilder < DfcBuilder
|
||||
add_ofn_property(e, "ofn:contact_name", enterprise.contact_name)
|
||||
|
||||
add_ofn_property(e, "ofn:logo_url", enterprise.logo.url)
|
||||
add_ofn_property(e, "ofn:promo_image_url", enterprise.promo_image.url)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ describe "Enterprises", type: :request, swagger_doc: "dfc.yaml", rswag_autodoc:
|
||||
let!(:user) { create(:oidc_user) }
|
||||
let!(:enterprise) do
|
||||
create(
|
||||
:distributor_enterprise, :with_logo_image,
|
||||
:distributor_enterprise, :with_logo_image, :with_promo_image,
|
||||
id: 10_000, owner: user, abn: "123 456", name: "Fred's Farm",
|
||||
description: "This is an awesome enterprise",
|
||||
contact_name: "Fred Farmer",
|
||||
@@ -80,6 +80,9 @@ describe "Enterprises", type: :request, swagger_doc: "dfc.yaml", rswag_autodoc:
|
||||
).gsub!(
|
||||
%r{active_storage/[0-9A-Za-z/=-]*/logo.png},
|
||||
"active_storage/url/logo.png",
|
||||
).gsub!(
|
||||
%r{active_storage/[0-9A-Za-z/=-]*/promo.png},
|
||||
"active_storage/url/promo.png",
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -29,7 +29,7 @@ FactoryBot.define do
|
||||
end
|
||||
|
||||
trait :with_promo_image do
|
||||
logo { Rack::Test::UploadedFile.new('spec/fixtures/files/promo.png', 'image/png') }
|
||||
promo_image { Rack::Test::UploadedFile.new('spec/fixtures/files/promo.png', 'image/png') }
|
||||
end
|
||||
|
||||
factory :supplier_enterprise, parent: :enterprise do
|
||||
|
||||
@@ -375,6 +375,7 @@ paths:
|
||||
ofn:long_description: "<p>Hello, world!</p><p>This is a paragraph.</p>"
|
||||
ofn:contact_name: Fred Farmer
|
||||
ofn:logo_url: http://www.example.com/rails/active_storage/url/logo.png
|
||||
ofn:promo_image_url: http://www.example.com/rails/active_storage/url/promo.png
|
||||
dfc-b:affiliates: http://test.host/api/dfc/enterprise_groups/60000
|
||||
- "@id": http://test.host/api/dfc/addresses/40000
|
||||
"@type": dfc-b:Address
|
||||
|
||||
Reference in New Issue
Block a user