Remove now useless wrapper class

This commit is contained in:
Maikel Linke
2025-01-30 10:11:03 +11:00
parent 236e706f2c
commit 1fcefcfcd0
3 changed files with 1 additions and 57 deletions

View File

@@ -1,7 +0,0 @@
# frozen_string_literal: true
class DfcProductTypeFactory
def self.for(dfc_id)
DataFoodConsortium::Connector::SKOSParser.concepts[dfc_id]
end
end

View File

@@ -107,7 +107,7 @@ class SuppliedProductBuilder < DfcBuilder
def self.product_type(variant)
taxon_dfc_id = variant.primary_taxon&.dfc_id
DfcProductTypeFactory.for(taxon_dfc_id)
DataFoodConsortium::Connector::SKOSParser.concepts[taxon_dfc_id]
end
def self.taxon(supplied_product)

View File

@@ -1,49 +0,0 @@
# frozen_string_literal: true
require_relative "../spec_helper"
RSpec.describe DfcProductTypeFactory do
describe ".for" do
let(:dfc_id) {
"https://github.com/datafoodconsortium/taxonomies/releases/latest/download/productTypes.rdf#drink"
}
it "assigns a top level product type" do
drink = DfcLoader.connector.PRODUCT_TYPES.DRINK
expect(described_class.for(dfc_id).semanticId).to eq drink.semanticId
end
context "with second level product type" do
let(:dfc_id) {
"https://github.com/datafoodconsortium/taxonomies/releases/latest/download/productTypes.rdf#soft-drink"
}
it "assigns a second level product type" do
soft_drink = DfcLoader.connector.PRODUCT_TYPES.DRINK.SOFT_DRINK
expect(described_class.for(dfc_id).semanticId).to eq soft_drink.semanticId
end
end
context "with leaf level product type" do
let(:dfc_id) {
"https://github.com/datafoodconsortium/taxonomies/releases/latest/download/productTypes.rdf#lemonade"
}
it "assigns a leaf level product type" do
lemonade = DfcLoader.connector.PRODUCT_TYPES.DRINK.SOFT_DRINK.LEMONADE
expect(described_class.for(dfc_id).semanticId).to eq lemonade.semanticId
end
end
context "with non existing product type" do
let(:dfc_id) { "other" }
it "returns nil" do
expect(described_class.for(dfc_id)).to be_nil
end
end
end
end