Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Cover per-field resolution within a single catalog

Damian Legawiec9665ca4d8263
diff --git a/spree/core/spec/services/spree/catalogs/resolve_quantity_rules_spec.rb b/spree/core/spec/services/spree/catalogs/resolve_quantity_rules_spec.rb
index 7e71be6d1e..bb8487b3e6 100644
--- a/spree/core/spec/services/spree/catalogs/resolve_quantity_rules_spec.rb
+++ b/spree/core/spec/services/spree/catalogs/resolve_quantity_rules_spec.rb
@@ -79,6 +79,17 @@ RSpec.describe Spree::Catalogs::ResolveQuantityRules do
expect(rule.multiple).to eq(6)
end
+ it "mixes an override field with the same catalog's default for the other" do
+ catalog = create(:catalog, store: store, minimum_order_quantity: 48, order_multiple: 24)
+ create(:catalog_quantity_rule, catalog: catalog, variant: variant,
+ minimum_order_quantity: 100, order_multiple: nil)
+
+ rule = described_class.new([catalog]).call(variant)
+
+ expect(rule.minimum).to eq(100)
+ expect(rule.multiple).to eq(24)
+ end
+
it 'mixes an override field with a further catalog for the other field' do
nearest = create(:catalog, store: store)
create(:catalog_quantity_rule, catalog: nearest, variant: variant,