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
Test the available_for_store? method
Matthew Kennedyf4ddc48c6376
diff --git a/core/spec/models/spree/payment_method_spec.rb b/core/spec/models/spree/payment_method_spec.rbindex eee3ae40b7..04c9d23ad9 100644--- a/core/spec/models/spree/payment_method_spec.rb+++ b/core/spec/models/spree/payment_method_spec.rb@@ -99,4 +99,25 @@ describe Spree::PaymentMethod, type: :model doendendend++ describe '#available_for_store?' do+ let!(:store) { create(:store) }+ let!(:store_1) { create(:store) }+ let!(:pm) { create(:credit_card_payment_method, stores: [store]) }++ it 'returns true when passed a nil value' do+ eligible = pm.available_for_store?(nil)+ expect(eligible).to be true+ end++ it 'returns false if currenct store id is not included' do+ ineligible = pm.available_for_store?(store_1)+ expect(ineligible).to be false+ end++ it 'returns true if currenct store id is included' do+ eligible = pm.available_for_store?(store)+ expect(eligible).to be true+ end+ endend