Files
openfoodnetwork/engines/dfc_provider/spec/services/offer_builder_spec.rb
Maikel Linke 583ac65920 Move building of Offer to the right module
The DfcBuilder was doing everything to start with but we are moving its
parts to smaller modules now.
2024-01-12 14:57:58 +11:00

31 lines
682 B
Ruby

# frozen_string_literal: true
require_relative "../spec_helper"
describe OfferBuilder 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 = OfferBuilder.build(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 = OfferBuilder.build(variant)
expect(offer.stockLimitation).to eq nil
end
end
end