diff --git a/engines/dfc_provider/app/services/enterprise_builder.rb b/engines/dfc_provider/app/services/enterprise_builder.rb index f5edfa4f5a..d1af0afad9 100644 --- a/engines/dfc_provider/app/services/enterprise_builder.rb +++ b/engines/dfc_provider/app/services/enterprise_builder.rb @@ -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 diff --git a/engines/dfc_provider/spec/requests/enterprises_spec.rb b/engines/dfc_provider/spec/requests/enterprises_spec.rb index ca875360ae..766a2d3beb 100644 --- a/engines/dfc_provider/spec/requests/enterprises_spec.rb +++ b/engines/dfc_provider/spec/requests/enterprises_spec.rb @@ -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 diff --git a/spec/factories/enterprise_factory.rb b/spec/factories/enterprise_factory.rb index 762d80c667..e29445941d 100644 --- a/spec/factories/enterprise_factory.rb +++ b/spec/factories/enterprise_factory.rb @@ -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 diff --git a/swagger/dfc.yaml b/swagger/dfc.yaml index b592fa742e..c4404a9086 100644 --- a/swagger/dfc.yaml +++ b/swagger/dfc.yaml @@ -375,6 +375,7 @@ paths: ofn:long_description: "

Hello, world!

This is a paragraph.

" 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