Add promo image to DFC Enterprise API

We want to use this image in the Discover Regenerative portal in
Australia. The property is read-only and the API doesn't support the
upload of a new file.

The enterprise factory needed fixing as well. This trait hadn't been
used anywhere else.
This commit is contained in:
Maikel Linke
2024-01-22 16:21:10 +11:00
parent a55587b765
commit fc75ea97a2
4 changed files with 11 additions and 2 deletions

View File

@@ -27,6 +27,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

View File

@@ -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",
@@ -73,6 +73,13 @@ describe "Enterprises", type: :request, swagger_doc: "dfc.yaml", rswag_autodoc:
%r{active_storage/[0-9A-Za-z/=-]*/logo.png},
"active_storage/url/logo.png",
)
response.body.gsub!(
%r{active_storage/[0-9A-Za-z/=-]*/promo.png},
"active_storage/url/promo.png",
).gsub!(
%r{active_storage/[0-9A-Za-z/=-]*/promo.png},
"active_storage/url/promo.png",
)
end
end
end

View File

@@ -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

View File

@@ -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