mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-10 23:07:47 +00:00
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.
31 lines
700 B
Ruby
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
|