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.

Prove the estimator path end to end in the EasyPost suite

Damian Legawieca620091891d3
diff --git a/spree/providers/easypost/spec/models/spree_easypost/delivery_rate_provider_spec.rb b/spree/providers/easypost/spec/models/spree_easypost/delivery_rate_provider_spec.rb
index f823cc78f1..27d9eb6852 100644
--- a/spree/providers/easypost/spec/models/spree_easypost/delivery_rate_provider_spec.rb
+++ b/spree/providers/easypost/spec/models/spree_easypost/delivery_rate_provider_spec.rb
@@ -174,4 +174,24 @@ RSpec.describe SpreeEasyPost::DeliveryRateProvider, 'API contract (VCR)' do
expect(estimate.metadata['easypost_shipment_id']).to be_present
end
end
+
+ # The whole path with nothing stubbed: Stock::Estimator resolves the
+ # integration from the database, the provider quotes over recorded HTTP,
+ # and the carrier fields land on the Spree::DeliveryRate the storefront
+ # reads.
+ it 'sets carrier and service level on the delivery rate end to end' do
+ delivery_method # lazy let — must exist before the estimator queries methods
+
+ VCR.use_cassette('create_shipment_rates') do
+ rates = Spree::Stock::Estimator.new(order).delivery_rates(package)
+ rate = rates.find { |candidate| candidate.delivery_method_id == delivery_method.id }
+
+ expect(rate).to be_a(Spree::DeliveryRate)
+ expect(rate.cost).to be > 0
+ expect(rate.carrier).to eq(recorded_rate['carrier'])
+ expect(rate.service_level).to eq(recorded_rate['service'])
+ expect(rate.metadata['easypost_rate_id']).to be_present
+ expect(rate.metadata['easypost_shipment_id']).to be_present
+ end
+ end
end