Files
openfoodnetwork/engines/dfc_provider/spec/services/offer_builder_spec.rb
Maikel Linke 78cf3b5a1d Serialize DFC catalog item with DFC Connector
This is work in progress. The DFC Connector uses a more recent DFC
version and other endpoints still use the old serializers. We need to
update those endpoints as well and update the version number in the API
URL.
2023-05-09 16:51:25 +10:00

31 lines
700 B
Ruby

# frozen_string_literal: true
require DfcProvider::Engine.root.join("spec/spec_helper")
describe DfcBuilder do
let(:variant) { build(:variant) }
describe ".offer" do
it "assigns a stock level" do
# Assigning stock only works with persisted records:
variant.save!
variant.on_hand = 5
offer = DfcBuilder.offer(variant)
expect(offer.stockLimitation).to eq 5
end
it "has no stock limitation when on demand" do
# Assigning stock only works with persisted records:
variant.save!
variant.on_hand = 5
variant.on_demand = true
offer = DfcBuilder.offer(variant)
expect(offer.stockLimitation).to eq nil
end
end
end