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.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Keep Spree::Pricing::Resolver working for one release
Damian Legawiec7821ce8aeb8b
diff --git a/spree/core/lib/spree/core.rb b/spree/core/lib/spree/core.rbindex e80eac1b0d..1ec73914b7 100644--- a/spree/core/lib/spree/core.rb+++ b/spree/core/lib/spree/core.rb@@ -792,3 +792,4 @@ require 'spree/core/permission_configuration'require 'spree/core/ransack_configuration'require 'spree/core/pricing/context'require 'spree/core/pricing/price_resolution'+require 'spree/core/pricing/resolver'diff --git a/spree/core/lib/spree/core/pricing/resolver.rb b/spree/core/lib/spree/core/pricing/resolver.rbnew file mode 100644index 0000000000..b6b0b19602--- /dev/null+++ b/spree/core/lib/spree/core/pricing/resolver.rb@@ -0,0 +1,33 @@+module Spree+ module Pricing+ # @deprecated Use {Spree::Pricing::PriceResolution}; removed in 6.1.+ #+ # Answering a price used to mean walking the store's price lists and+ # falling back to the variant's base price. That is now one engine among+ # several — {Spree::PricingProvider::Internal} — and choosing between them+ # is {PriceResolution}'s job.+ #+ # The contract differs in one way worth knowing before switching: a+ # configured external provider that cannot answer raises+ # {PriceResolution::ProviderUnavailable} under a store's +strict+ pricing+ # policy, where this class could only ever return a price or nil.+ class Resolver+ attr_reader :context++ # @param context [Spree::Pricing::Context]+ def initialize(context)+ @context = context+ end++ # @return [Spree::Price, nil]+ def resolve+ Spree::Deprecation.warn(+ 'Spree::Pricing::Resolver is deprecated and will be removed in Spree 6.1. ' \+ 'Use Spree::Pricing::PriceResolution.call(context) instead.'+ )++ Spree::Pricing::PriceResolution.call(context)+ end+ end+ end+enddiff --git a/spree/core/spec/lib/spree/pricing/resolver_spec.rb b/spree/core/spec/lib/spree/pricing/resolver_spec.rbnew file mode 100644index 0000000000..88c4c306cd--- /dev/null+++ b/spree/core/spec/lib/spree/pricing/resolver_spec.rb@@ -0,0 +1,27 @@+require 'spec_helper'++# The pre-6.0 entry point for pricing a variant. Kept working for one release+# because host apps and extensions called it directly.+describe Spree::Pricing::Resolver do+ let(:store) { @default_store }+ let(:variant) { create(:variant, price: 12) }+ let(:context) { Spree::Pricing::Context.new(variant: variant, currency: 'USD', store: store) }++ it 'still answers the catalog price' do+ allow(Spree::Deprecation).to receive(:warn)++ price = described_class.new(context).resolve++ expect(price.amount).to eq(12)+ end++ it 'warns that it has moved' do+ expect(Spree::Deprecation).to receive(:warn).with(/Spree::Pricing::Resolver is deprecated.*PriceResolution/m)++ described_class.new(context).resolve+ end++ it 'exposes the context it was built with' do+ expect(described_class.new(context).context).to eq(context)+ end+end