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
Fix `Spree::ShippingMethod.available` scope (#12102)
Łukasz Adamczyk2d2f4fd289b9
diff --git a/core/app/models/spree/shipping_method.rb b/core/app/models/spree/shipping_method.rbindex 1bdeb5087e..740580b455 100644--- a/core/app/models/spree/shipping_method.rb+++ b/core/app/models/spree/shipping_method.rb@@ -35,7 +35,7 @@ module Spreevalidate :at_least_one_shipping_category- scope :available, -> { where(display_on: [:front_end, :back_end, :both]) }+ scope :available, -> { where(display_on: [:both]) }scope :available_on_front_end, -> { where(display_on: [:front_end, :both]) }scope :available_on_back_end, -> { where(display_on: [:back_end, :both]) }diff --git a/core/spec/models/spree/shipping_method_spec.rb b/core/spec/models/spree/shipping_method_spec.rbindex 8dc1044dcd..4195f55e6d 100644--- a/core/spec/models/spree/shipping_method_spec.rb+++ b/core/spec/models/spree/shipping_method_spec.rb@@ -11,6 +11,30 @@ describe Spree::ShippingMethod, type: :model doit_behaves_like 'metadata'+ describe 'scopes' do+ let!(:shipping_methods) { create_list(:shipping_method, 2, display_on: 'both') }+ let!(:frontend_shipping_methods) { create_list(:shipping_method, 2, display_on: 'front_end') }+ let!(:backend_shipping_methods) { create_list(:shipping_method, 2, display_on: 'back_end') }++ describe '.available' do+ subject { described_class.available }++ it { is_expected.to match_array(shipping_methods) }+ end++ describe '.available_on_front_end' do+ subject { described_class.available_on_front_end }++ it { is_expected.to match_array(shipping_methods + frontend_shipping_methods) }+ end++ describe '.available_on_back_end' do+ subject { described_class.available_on_back_end }++ it { is_expected.to match_array(shipping_methods + backend_shipping_methods) }+ end+ end+context 'calculators' doit "rejects calculators that don't inherit from Spree::ShippingCalculator" doallow(Spree::ShippingMethod).to receive_message_chain(:spree_calculators, :shipping_methods).and_return([