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
[SD-1331] Assign Store to Payment Method factory (#11063)
Łukasz Adamczyka037f916d4ed
diff --git a/api/spec/requests/spree/api/v2/storefront/checkout_spec.rb b/api/spec/requests/spree/api/v2/storefront/checkout_spec.rbindex ca0f3edea5..e29b206991 100644--- a/api/spec/requests/spree/api/v2/storefront/checkout_spec.rb+++ b/api/spec/requests/spree/api/v2/storefront/checkout_spec.rb@@ -224,7 +224,7 @@ describe 'API V2 Storefront Checkout Spec', type: :request dolet!(:stock_location) { create(:stock_location) }let!(:shipping_method) { create(:shipping_method, zones: [country_zone]) }- let!(:payment_method) { create(:credit_card_payment_method) }+ let!(:payment_method) { create(:credit_card_payment_method, stores: [store]) }let(:execute) { patch '/api/v2/storefront/checkout', params: params, headers: headers }@@ -545,7 +545,7 @@ describe 'API V2 Storefront Checkout Spec', type: :request dodescribe 'checkout#payment_methods' dolet(:execute) { get '/api/v2/storefront/checkout/payment_methods', headers: headers }- let!(:payment_method) { create(:credit_card_payment_method) }+ let!(:payment_method) { create(:credit_card_payment_method, stores: [store]) }let(:payment_methods) { order.available_payment_methods }shared_examples 'returns a list of available payment methods' dodiff --git a/core/lib/spree/testing_support/factories/payment_method_factory.rb b/core/lib/spree/testing_support/factories/payment_method_factory.rbindex 2415d49c13..316c97222e 100644--- a/core/lib/spree/testing_support/factories/payment_method_factory.rb+++ b/core/lib/spree/testing_support/factories/payment_method_factory.rb@@ -1,15 +1,28 @@FactoryBot.define do- factory :check_payment_method, class: Spree::PaymentMethod::Check do+ factory :payment_method, class: Spree::PaymentMethod do+ name { 'Test' }++ before(:create) do |payment_method|+ if payment_method.stores.empty?+ default_store = Spree::Store.default.persisted? ? Spree::Store.default : nil+ store = default_store || create(:store)++ payment_method.stores << [store]+ end+ end+ end++ factory :check_payment_method, parent: :payment_method, class: Spree::PaymentMethod::Check doname { 'Check' }end- factory :credit_card_payment_method, class: Spree::Gateway::Bogus do+ factory :credit_card_payment_method, parent: :payment_method, class: Spree::Gateway::Bogus doname { 'Credit Card' }end# authorize.net was moved to spree_gateway.# Leaving this factory in place with bogus in case anyone is using it.- factory :simple_credit_card_payment_method, class: Spree::Gateway::BogusSimple do+ factory :simple_credit_card_payment_method, parent: :payment_method, class: Spree::Gateway::BogusSimple doname { 'Credit Card' }end