mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
List groups when showing DFC Enterprise
This commit is contained in:
@@ -7,6 +7,12 @@ module DfcProvider
|
||||
|
||||
def show
|
||||
enterprise = EnterpriseBuilder.enterprise(current_enterprise)
|
||||
|
||||
group_ids = current_enterprise.groups.map do |group|
|
||||
DfcProvider::Engine.routes.url_helpers.enterprise_group_url(group.id)
|
||||
end
|
||||
enterprise.registerSemanticProperty("dfc-b:affiliates") { group_ids }
|
||||
|
||||
render json: DfcIo.export(
|
||||
enterprise,
|
||||
*enterprise.localizations,
|
||||
|
||||
@@ -12,6 +12,13 @@ describe "Enterprises", type: :request, swagger_doc: "dfc.yaml", rswag_autodoc:
|
||||
address: build(:address, id: 40_000, address1: "42 Doveton Street"),
|
||||
)
|
||||
end
|
||||
let!(:enterprise_group) do
|
||||
create(
|
||||
:enterprise_group,
|
||||
id: 60_000, owner: user, name: "Local Farmers",
|
||||
enterprises: [enterprise],
|
||||
)
|
||||
end
|
||||
let!(:product) {
|
||||
create(
|
||||
:base_product,
|
||||
@@ -48,6 +55,10 @@ describe "Enterprises", type: :request, swagger_doc: "dfc.yaml", rswag_autodoc:
|
||||
expect(response.body).to include "123 456"
|
||||
expect(response.body).to include "Apple"
|
||||
expect(response.body).to include "42 Doveton Street"
|
||||
|
||||
expect(json_response["@graph"][0]).to include(
|
||||
"dfc-b:affiliates" => "http://test.host/api/dfc/enterprise_groups/60000",
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -313,6 +313,7 @@ paths:
|
||||
dfc-b:VATnumber: 123 456
|
||||
dfc-b:supplies: http://test.host/api/dfc/enterprises/10000/supplied_products/10001
|
||||
dfc-b:manages: http://test.host/api/dfc/enterprises/10000/catalog_items/10001
|
||||
dfc-b:affiliates: http://test.host/api/dfc/enterprise_groups/60000
|
||||
- "@id": http://test.host/api/dfc/addresses/40000
|
||||
"@type": dfc-b:Address
|
||||
dfc-b:hasStreet: 42 Doveton Street
|
||||
|
||||
Reference in New Issue
Block a user