List groups when showing DFC Enterprise

This commit is contained in:
Maikel Linke
2023-09-07 14:13:39 +10:00
parent cf18229e5b
commit 88a3615de7
3 changed files with 18 additions and 0 deletions

View File

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

View File

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

View File

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